Changeset 25cdca5


Ignore:
Timestamp:
Jan 8, 2019, 11:31:21 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
08222c7, 274da98
Parents:
84b4d607 (diff), d5b2ac8 (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:
21 added
25 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 08:34:28 2018
    13 // Update Count     : 298
     12// Last Modified On : Mon Dec 24 18:33:38 2018
     13// Update Count     : 304
    1414//
    1515
     
    2626#define IO_MSG "I/O error: "
    2727
    28 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool nonlManip, const char * separator, const char * tupleSeparator ) {
     28void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool prt, const char * separator, const char * tupleSeparator ) {
    2929        os.file = file;
    3030        os.sepDefault = sepDefault;
    3131        os.sepOnOff = sepOnOff;
    3232        os.nlOnOff = nlOnOff;
    33         os.nonlManip = nonlManip;
     33        os.prt = prt;
    3434        sepSet( os, separator );
    3535        sepSetCur( os, sepGet( os ) );
     
    4646void setNL( ofstream & os, bool state ) { os.sawNL = state; }
    4747bool getANL( ofstream & os ) { return os.nlOnOff; }
    48 bool getNonl( ofstream & os ) { return os.nonlManip; }
    49 void setNonl( ofstream & os, bool state ) { os.nonlManip = state; }
     48bool getPrt( ofstream & os ) { return os.prt; }
     49void setPrt( ofstream & os, bool state ) { os.prt = state; }
    5050
    5151// public
     
    150150        va_end( args );
    151151
     152        setPrt( os, true );                                                                     // called in output cascade
    152153        sepReset( os );                                                                         // reset separator
    153154        return len;
  • libcfa/src/fstream.hfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 07:52:41 2018
    13 // Update Count     : 143
     12// Last Modified On : Mon Dec 24 18:33:41 2018
     13// Update Count     : 149
    1414//
    1515
     
    2424        bool sepOnOff;
    2525        bool nlOnOff;
    26         bool nonlManip;
     26        bool prt;                                                                                       // print text
    2727        bool sawNL;
    2828        const char * sepCur;
     
    4040void setNL( ofstream &, bool );
    4141bool getANL( ofstream & );
    42 bool getNonl( ofstream & );
    43 void setNonl( ofstream &, bool );
     42bool getPrt( ofstream & );
     43void setPrt( ofstream &, bool );
    4444
    4545// public
     
    6262void close( ofstream & );
    6363ofstream & write( ofstream &, const char * data, size_t size );
    64 int fmt( ofstream &, const char fmt[], ... );
     64int fmt( ofstream &, const char format[], ... );
    6565
    6666void ?{}( ofstream & os );
     
    8383ifstream & read( ifstream & is, char * data, size_t size );
    8484ifstream & ungetc( ifstream & is, char c );
    85 int fmt( ifstream &, const char fmt[], ... );
     85int fmt( ifstream &, const char format[], ... );
    8686
    8787void ?{}( ifstream & is );
  • libcfa/src/iostream.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 13 14:13:22 2018
    13 // Update Count     : 548
     12// Last Modified On : Mon Dec 24 18:33:40 2018
     13// Update Count     : 589
    1414//
    1515
     
    3333        } // ?|?
    3434        void ?|?( ostype & os, bool b ) {
    35                 (ostype)(os | b); if ( getANL( os ) ) nl( os );
     35                (ostype &)(os | b); nl( os );
    3636        } // ?|?
    3737
     
    4242        } // ?|?
    4343        void ?|?( ostype & os, char c ) {
    44                 (ostype)(os | c); if ( getANL( os ) ) nl( os );
     44                (ostype &)(os | c); nl( os );
    4545        } // ?|?
    4646
     
    5151        } // ?|?
    5252        void ?|?( ostype & os, signed char sc ) {
    53                 (ostype)(os | sc); if ( getANL( os ) ) nl( os );
     53                (ostype &)(os | sc); nl( os );
    5454        } // ?|?
    5555
     
    6060        } // ?|?
    6161        void ?|?( ostype & os, unsigned char usc ) {
    62                 (ostype)(os | usc); if ( getANL( os ) ) nl( os );
     62                (ostype &)(os | usc); nl( os );
    6363        } // ?|?
    6464
     
    6969        } // ?|?
    7070        void & ?|?( ostype & os, short int si ) {
    71                 (ostype)(os | si); if ( getANL( os ) ) nl( os );
     71                (ostype &)(os | si); nl( os );
    7272        } // ?|?
    7373
     
    7878        } // ?|?
    7979        void & ?|?( ostype & os, unsigned short int usi ) {
    80                 (ostype)(os | usi); if ( getANL( os ) ) nl( os );
     80                (ostype &)(os | usi); nl( os );
    8181        } // ?|?
    8282
     
    8787        } // ?|?
    8888        void & ?|?( ostype & os, int i ) {
    89                 (ostype)(os | i); if ( getANL( os ) ) nl( os );
     89                (ostype &)(os | i); nl( os );
    9090        } // ?|?
    9191
     
    9696        } // ?|?
    9797        void & ?|?( ostype & os, unsigned int ui ) {
    98                 (ostype)(os | ui); if ( getANL( os ) ) nl( os );
     98                (ostype &)(os | ui); nl( os );
    9999        } // ?|?
    100100
     
    105105        } // ?|?
    106106        void & ?|?( ostype & os, long int li ) {
    107                 (ostype)(os | li); if ( getANL( os ) ) nl( os );
     107                (ostype &)(os | li); nl( os );
    108108        } // ?|?
    109109
     
    114114        } // ?|?
    115115        void & ?|?( ostype & os, unsigned long int uli ) {
    116                 (ostype)(os | uli); if ( getANL( os ) ) nl( os );
     116                (ostype &)(os | uli); nl( os );
    117117        } // ?|?
    118118
     
    123123        } // ?|?
    124124        void & ?|?( ostype & os, long long int lli ) {
    125                 (ostype)(os | lli); if ( getANL( os ) ) nl( os );
     125                (ostype &)(os | lli); nl( os );
    126126        } // ?|?
    127127
     
    132132        } // ?|?
    133133        void & ?|?( ostype & os, unsigned long long int ulli ) {
    134                 (ostype)(os | ulli); if ( getANL( os ) ) nl( os );
     134                (ostype &)(os | ulli); nl( os );
    135135        } // ?|?
    136136
     
    141141        } // ?|?
    142142        void & ?|?( ostype & os, float f ) {
    143                 (ostype)(os | f); if ( getANL( os ) ) nl( os );
     143                (ostype &)(os | f); nl( os );
    144144        } // ?|?
    145145
     
    150150        } // ?|?
    151151        void & ?|?( ostype & os, double d ) {
    152                 (ostype)(os | d); if ( getANL( os ) ) nl( os );
     152                (ostype &)(os | d); nl( os );
    153153        } // ?|?
    154154
     
    159159        } // ?|?
    160160        void & ?|?( ostype & os, long double ld ) {
    161                 (ostype)(os | ld); if ( getANL( os ) ) nl( os );
     161                (ostype &)(os | ld); nl( os );
    162162        } // ?|?
    163163
     
    168168        } // ?|?
    169169        void & ?|?( ostype & os, float _Complex fc ) {
    170                 (ostype)(os | fc); if ( getANL( os ) ) nl( os );
     170                (ostype &)(os | fc); nl( os );
    171171        } // ?|?
    172172
     
    177177        } // ?|?
    178178        void & ?|?( ostype & os, double _Complex dc ) {
    179                 (ostype)(os | dc); if ( getANL( os ) ) nl( os );
     179                (ostype &)(os | dc); nl( os );
    180180        } // ?|?
    181181
     
    186186        } // ?|?
    187187        void & ?|?( ostype & os, long double _Complex ldc ) {
    188                 (ostype)(os | ldc); if ( getANL( os ) ) nl( os );
     188                (ostype &)(os | ldc); nl( os );
    189189        } // ?|?
    190190
     
    228228        } // ?|?
    229229        void ?|?( ostype & os, const char * str ) {
    230                 (ostype)(os | str); if ( getANL( os ) ) nl( os );
     230                (ostype &)(os | str); nl( os );
    231231        } // ?|?
    232232
     
    257257        } // ?|?
    258258        void ?|?( ostype & os, const void * p ) {
    259                 (ostype)(os | p); if ( getANL( os ) ) nl( os );
     259                (ostype &)(os | p); nl( os );
    260260        } // ?|?
    261261
    262262        // manipulators
    263263        ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    264                 (ostype)(manip( os ));
    265                 setNonl( os, false );                                                   // ignore nonl in middle
     264                (ostype &)(manip( os ));
    266265                return os;
    267266        } // ?|?
    268267        void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    269                 (ostype)(manip( os ));
    270                 if ( getANL( os ) && ! getNonl( os ) ) nl( os ); // ignore nl if nonl at end
    271                 setNonl( os, false );
     268                (ostype &)(manip( os ));
     269                if ( getPrt( os ) ) nl( os );                                   // something printed ?
     270                setPrt( os, false );                                                    // turn off
    272271        } // ?|?
    273272
    274273        ostype & sep( ostype & os ) {
    275                 return (ostype)(os | sepGet( os ));
     274                return (ostype &)(os | sepGet( os ));
    276275        } // sep
    277276
     
    281280
    282281        ostype & nl( ostype & os ) {
    283                 (ostype)(os | '\n');
     282                (ostype &)(os | '\n');
     283                setPrt( os, false );                                                    // turn off
    284284                setNL( os, true );
    285285                flush( os );
     
    287287        } // nl
    288288
     289        void nl( ostype & os ) {
     290                if ( getANL( os ) ) (ostype &)(nl( os ));               // implementation only
     291                else setPrt( os, false );                                               // turn off
     292        } // nl
     293
    289294        ostype & nonl( ostype & os ) {
    290                 setNonl( os, true );                                                    // indicate nonl manipulator
     295                setPrt( os, false );                                                    // turn off
    291296                return os;
    292297        } // nonl
     
    326331forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {
    327332        ostype & ?|?( ostype & os, T arg, Params rest ) {
    328                 (ostype)(os | arg);                                                             // print first argument
     333                (ostype &)(os | arg);                                                   // print first argument
    329334                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    330                 (ostype)(os | rest);                                                    // print remaining arguments
     335                (ostype &)(os | rest);                                                  // print remaining arguments
    331336                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    332337                return os;
    333338        } // ?|?
    334339        void ?|?( ostype & os, T arg, Params rest ) {
    335 //              (ostype)(?|?( os, arg, rest )); if ( getANL( os ) ) nl( os );
    336                 (ostype)(os | arg);                                                             // print first argument
     340                // (ostype &)(?|?( os, arg, rest )); nl( os );
     341                (ostype &)(os | arg);                                                   // print first argument
    337342                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    338                 (ostype)(os | rest);                                                    // print remaining arguments
     343                (ostype &)(os | rest);                                                  // print remaining arguments
    339344                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    340                 if ( getANL( os ) ) nl( os );
     345                nl( os );
    341346        } // ?|?
    342347} // distribution
  • libcfa/src/iostream.hfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:01:31 2018
    13 // Update Count     : 213
     12// Last Modified On : Mon Dec 24 18:33:40 2018
     13// Update Count     : 220
    1414//
    1515
     
    2020trait ostream( dtype ostype ) {
    2121        // private
    22         bool sepPrt( ostype & );                                                        // return separator state (on/off)
     22        bool sepPrt( ostype & );                                                        // get separator state (on/off)
    2323        void sepReset( ostype & );                                                      // set separator state to default state
    2424        void sepReset( ostype &, bool );                                        // set separator and default state
     
    2727        bool getNL( ostype & );                                                         // check newline
    2828        void setNL( ostype &, bool );                                           // saw newline
    29         bool getANL( ostype & );                                                        // check auto newline
    30         bool getNonl( ostype & );                                                       // check nonnl manipulator
    31         void setNonl( ostype &, bool );                                         // set nonnl manipulator
     29        bool getANL( ostype & );                                                        // get auto newline (on/off)
     30        bool getPrt( ostype & );                                                        // get fmt called in output cascade
     31        void setPrt( ostype &, bool );                                          // set fmt called in output cascade
    3232        // public
    3333        void sepOn( ostype & );                                                         // turn separator state on
     
    4848        void close( ostype & os );
    4949        ostype & write( ostype &, const char *, size_t );
    50         int fmt( ostype &, const char fmt[], ... );
     50        int fmt( ostype &, const char format[], ... );
    5151}; // ostream
    5252
     
    6363forall( dtype ostype | ostream( ostype ) ) {
    6464        ostype & ?|?( ostype &, bool );
    65         void & ?|?( ostype &, bool );
     65        void ?|?( ostype &, bool );
    6666
    6767        ostype & ?|?( ostype &, char );
    68         void & ?|?( ostype &, char );
     68        void ?|?( ostype &, char );
    6969        ostype & ?|?( ostype &, signed char );
    70         void & ?|?( ostype &, signed char );
     70        void ?|?( ostype &, signed char );
    7171        ostype & ?|?( ostype &, unsigned char );
    72         void & ?|?( ostype &, unsigned char );
     72        void ?|?( ostype &, unsigned char );
    7373
    7474        ostype & ?|?( ostype &, short int );
    75         void & ?|?( ostype &, short int );
     75        void ?|?( ostype &, short int );
    7676        ostype & ?|?( ostype &, unsigned short int );
    77         void & ?|?( ostype &, unsigned short int );
     77        void ?|?( ostype &, unsigned short int );
    7878        ostype & ?|?( ostype &, int );
    79         void & ?|?( ostype &, int );
     79        void ?|?( ostype &, int );
    8080        ostype & ?|?( ostype &, unsigned int );
    81         void & ?|?( ostype &, unsigned int );
     81        void ?|?( ostype &, unsigned int );
    8282        ostype & ?|?( ostype &, long int );
    83         void & ?|?( ostype &, long int );
     83        void ?|?( ostype &, long int );
    8484        ostype & ?|?( ostype &, long long int );
    85         void & ?|?( ostype &, long long int );
     85        void ?|?( ostype &, long long int );
    8686        ostype & ?|?( ostype &, unsigned long int );
    87         void & ?|?( ostype &, unsigned long int );
     87        void ?|?( ostype &, unsigned long int );
    8888        ostype & ?|?( ostype &, unsigned long long int );
    89         void & ?|?( ostype &, unsigned long long int );
     89        void ?|?( ostype &, unsigned long long int );
    9090
    9191        ostype & ?|?( ostype &, float ); // FIX ME: should not be required
    92         void & ?|?( ostype &, float ); // FIX ME: should not be required
     92        void ?|?( ostype &, float ); // FIX ME: should not be required
    9393        ostype & ?|?( ostype &, double );
    94         void & ?|?( ostype &, double );
     94        void ?|?( ostype &, double );
    9595        ostype & ?|?( ostype &, long double );
    96         void & ?|?( ostype &, long double );
     96        void ?|?( ostype &, long double );
    9797
    9898        ostype & ?|?( ostype &, float _Complex );
    99         void & ?|?( ostype &, float _Complex );
     99        void ?|?( ostype &, float _Complex );
    100100        ostype & ?|?( ostype &, double _Complex );
    101         void & ?|?( ostype &, double _Complex );
     101        void ?|?( ostype &, double _Complex );
    102102        ostype & ?|?( ostype &, long double _Complex );
    103         void & ?|?( ostype &, long double _Complex );
     103        void ?|?( ostype &, long double _Complex );
    104104
    105105        ostype & ?|?( ostype &, const char * );
    106         void & ?|?( ostype &, const char * );
     106        void ?|?( ostype &, const char * );
    107107        // ostype & ?|?( ostype &, const char16_t * );
    108108#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     
    111111        // ostype & ?|?( ostype &, const wchar_t * );
    112112        ostype & ?|?( ostype &, const void * );
    113         void & ?|?( ostype &, const void * );
     113        void ?|?( ostype &, const void * );
    114114
    115115        // manipulators
     
    117117        void ?|?( ostype &, ostype & (*)( ostype & ) );
    118118        ostype & nl( ostype & );
     119        void nl( ostype & );
    119120        ostype & nonl( ostype & );
    120121        ostype & sep( ostype & );
     
    149150        istype & read( istype &, char *, size_t );
    150151        istype & ungetc( istype &, char );
    151         int fmt( istype &, const char fmt[], ... );
     152        int fmt( istype &, const char format[], ... );
    152153}; // istream
    153154
  • libcfa/src/rational.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:02:29 2018
    13 // Update Count     : 168
     12// Last Modified On : Sun Dec 23 22:56:49 2018
     13// Update Count     : 170
    1414//
    1515
     
    181181
    182182                void ?|?( ostype & os, Rational(RationalImpl) r ) {
    183                         (ostype)(os | r); if ( getANL( os ) ) nl( os );
     183                        (ostype &)(os | r); nl( os );
    184184                } // ?|?
    185185        } // distribution
  • libcfa/src/stdlib.hfa

    r84b4d607 r25cdca5  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 27 07:21:36 2018
    13 // Update Count     : 345
     12// Last Modified On : Mon Dec 17 15:37:45 2018
     13// Update Count     : 346
    1414//
    1515
     
    178178
    179179static inline {
    180         int ato( const char * sptr ) {return (int)strtol( sptr, 0, 10 ); }
     180        int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); }
    181181        unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); }
    182182        long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); }
  • libcfa/src/time.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:32:15 2018
    13 // Update Count     : 53
     12// Last Modified On : Sun Dec 23 22:57:48 2018
     13// Update Count     : 57
    1414//
    1515
     
    3333forall( dtype ostype | ostream( ostype ) ) {
    3434        ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
    35                 (ostype)(os | tv / TIMEGRAN);                                   // print seconds
     35                (ostype &)(os | tv / TIMEGRAN);                                 // print seconds
    3636                long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
    3737                if ( ns != 0 ) {                                                                // some ?
    3838                        char buf[16];
    39                         (ostype)(os | nanomsd( ns, buf ));                      // print nanoseconds
     39                        (ostype &)(os | nanomsd( ns, buf ));                    // print nanoseconds
    4040                } // if
    4141                return os;
     
    4343
    4444        void ?|?( ostype & os, Duration dur ) with( dur ) {
    45                 (ostype)(os | dur); if ( getANL( os ) ) nl( os );
     45                (ostype &)(os | dur); nl( os );
    4646        } // ?|?
    4747} // distribution
     
    150150                long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
    151151                if ( ns == 0 ) {                                                                // none ?
    152                         (ostype)(os | buf);                                                     // print date/time/year
     152                        (ostype &)(os | buf);                                                   // print date/time/year
    153153                } else {
    154154                        buf[19] = '\0';                                                         // truncate to "Wed Jun 30 21:49:08"
    155155                        char buf2[16];
    156156                        nanomsd( ns, buf2 );                                            // compute nanoseconds
    157                         (ostype)(os | buf | buf2 | ' ' | &buf[20]);     // print date/time, nanoseconds and year
     157                        (ostype &)(os | buf | buf2 | ' ' | &buf[20]);   // print date/time, nanoseconds and year
    158158                } // if
    159159                return os;
     
    161161
    162162        void ?|?( ostype & os, Time time ) with( time ) {
    163                 (ostype)(os | time); if ( getANL( os ) ) nl( os );
     163                (ostype &)(os | time); nl( os );
    164164        } // ?|?
    165165} // distribution
  • tests/concurrent/examples/quickSort.cfa

    r84b4d607 r25cdca5  
    99// Created On       : Wed Dec  6 12:15:52 2017
    1010// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Tue Dec  4 18:00:27 2018
    12 // Update Count     : 167
     11// Last Modified On : Sat Dec 22 08:44:27 2018
     12// Update Count     : 168
    1313//
    1414
     
    151151                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    152152                        } // for
    153                         sortedfile | nl;
     153                        sortedfile | nl | nl;
    154154
    155155                        delete( values );
  • tests/coroutine/fmtLines.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 22:45:36 2018
    13 // Update Count     : 48
     12// Last Modified On : Sat Dec 22 18:27:00 2018
     13// Update Count     : 57
    1414//
    1515
     
    2424void main( Format & fmt ) with( fmt ) {
    2525        for () {                                                                                        // for as many characters
    26                 for ( g; 5 ) {                                                                  // groups of 5 blocks
    27                         for ( b; 4 ) {                                                          // blocks of 4 characters
     26                for ( g = 0; g < 5; g += 1 ) {                                  // groups of 5 blocks
     27                        for ( b = 0; b < 4; b += 1 ) {                          // blocks of 4 characters
    2828                                for () {                                                                // for newline characters
    2929                                        suspend();
    30                                         if ( ch != '\n' ) break;                        // ignore newline
     30                                  if ( ch != '\n' ) break;                              // ignore newline
    3131                                } // for
    3232                                sout | ch;                                                              // print character
  • tests/fallthrough.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Mar 14 10:06:25 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 21:36:14 2018
    13 // Update Count     : 17
     12// Last Modified On : Mon Dec 24 11:24:35 2018
     13// Update Count     : 22
    1414//
    1515
     
    1818void test(int choice) {
    1919        choose ( choice ) {
    20                 case 1:
    21                         sout | "case 1";
    22                         fallthru;
    23                 case 2:
    24                         sout | "case 2";
    25                         fallthru;
    26                         sout | "did not fallthru";
    27                         if ( 7 ) fallthru common2;
    28                         fallthru common1;
    29                 case 3:
    30                         sout | "case 3";
    31                         fallthru default;
    32                         fallthru common1;
    33                 common1:
    34                         sout | "common1";
     20          case 1:
     21                sout | "case 1";
     22                fallthru;
     23          case 2:
     24                sout | "case 2";
     25                fallthru;
     26                sout | "did not fallthru";
     27                if ( 7 ) fallthru common2;
     28                fallthru common1;
     29          case 3:
     30                sout | "case 3";
     31                fallthru default;
     32                fallthru common1;
     33          common1:
     34                sout | "common1";
    3535                // break
    36                 case 4:
    37                         sout | "case 4";
    38                         fallthru common2;
    39                 case 5:
    40                         sout | "case 5";
    41                         fallthru common2;
    42                         fallthru default;
    43                 case 6:
    44                         sout | "case 6";
    45                         fallthru common2;
    46                 common2:
    47                         sout | "common2";
     36          case 4:
     37                sout | "case 4";
     38                fallthru common2;
     39          case 5:
     40                sout | "case 5";
     41                fallthru common2;
     42                fallthru default;
     43          case 6:
     44                sout | "case 6";
     45                fallthru common2;
     46          common2:
     47                sout | "common2";
    4848                // break
    49                 default:
    50                         sout | "default";
    51                         fallthru;
    52         }
     49          default:
     50                sout | "default";
     51                fallthru;
     52        } // choose
    5353
    5454        sout | nl;
     
    6161                        sout | "case 1";
    6262                        for ( int i = 0; i < 4; i += 1 ) {
    63                                 printf("%d\n", i);
     63                                sout | i;
    6464                                if ( i == 2 ) fallthru common;
    6565                        } // for
     
    7777                } // if
    7878          common:
    79                 printf( "common\n" );
     79                sout | "common";
    8080                fallthru;
    8181                break;
    8282          default:
    83                 printf( "default\n" );
     83                sout | "default";
    8484                fallthru;
    8585        } // switch
     
    9393        fallthru default;
    9494        choose ( 3 ) {
    95                 case 2:
    96                         for () {
    97                                 choose ( 2 ) {
    98                                         case 1:
    99                                                 // ERROR: default is later, but in a different switch
    100                                                 fallthru default;
    101                                                 // ERROR: common3 is later, but not at the same level as a case clause
    102                                                 fallthru common3;
    103                                 }
    104                                 common3: ;
     95          case 2:
     96                for () {
     97                        choose ( 2 ) {
     98                          case 1:
     99                                // ERROR: default is later, but in a different switch
     100                                fallthru default;
     101                                // ERROR: common3 is later, but not at the same level as a case clause
     102                                fallthru common3;
    105103                        }
    106                 default:
    107                 case 1:
    108                 common4:
    109                         // ERROR: attempt to jump up with fallthrough
    110                         if ( 7 ) fallthru common4;
    111                         // ERROR: attempt to jump up with fallthrough
    112                         fallthru default;
    113         }
     104                  common3: ;
     105                } // for
     106          default:
     107          case 1:
     108          common4:
     109                // ERROR: attempt to jump up with fallthrough
     110                if ( 7 ) fallthru common4;
     111                // ERROR: attempt to jump up with fallthrough
     112                fallthru default;
     113        } // choose
    114114#endif
    115115}
  • tests/fstream_test.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 21:36:34 2018
    13 // Update Count     : 67
     12// Last Modified On : Sat Dec 22 09:47:44 2018
     13// Update Count     : 68
    1414//
    1515
     
    2424                 | (nombre > 0 ? "positif" : nombre == 0 ? "zéro" : "négatif");
    2525
    26         sout | "Entrez trois nombres, s'il vous plaît: ";
     26        sout | "Entrez trois nombres, s'il vous plaît:";
    2727        int i, j, k;
    2828        sin  | i | j | k;
  • tests/genericUnion.cfa

    r84b4d607 r25cdca5  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// genericUnion.cfa --
     8//
     9// Author           : Peter A. Buhr
     10// Created On       : Tue Dec 25 14:42:46 2018
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Dec 25 14:46:33 2018
     13// Update Count     : 2
     14//
     15
    116#include <limits.hfa>
    217
     
    419union ByteView {
    520        T val;
    6         char bytes[(sizeof(int))]; // want to change to sizeof(T)
     21        char bytes[(sizeof(int))];                                                      // want to change to sizeof(T)
    722};
    823
    924forall(otype T)
    1025void print(ByteView(T) x) {
    11         for (int i = 0; i < sizeof(int); i++) { // want to change to sizeof(T)
     26        for (int i = 0; i < sizeof(int); i++) {                         // want to change to sizeof(T)
    1227                printf("%02x", x.bytes[i] & 0xff);
    1328        }
     
    2944        f(i, -1);
    3045}
     46
     47// Local Variables: //
     48// tab-width: 4 //
     49// compile-command: "cfa genericUnion.cfa" //
     50// End: //
  • tests/gmp.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 21:37:29 2018
    13 // Update Count     : 558
     12// Last Modified On : Thu Dec 20 22:41:47 2018
     13// Update Count     : 559
    1414//
    1515
     
    7676        sout | "x:" | x | "y:" | y;
    7777
    78         sout;
     78        sout | nl;
    7979
    8080        sin | x | y | z;
    8181        sout | x | y | z;
    8282
    83         sout;
     83        sout | nl;
    8484
    8585        sout | "Fibonacci Numbers";
     
    9494        } // for
    9595
    96         sout;
     96        sout | nl;
    9797
    9898        sout | "Factorial Numbers";
  • tests/io1.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 18:23:44 2018
    13 // Update Count     : 110
     12// Last Modified On : Fri Dec 21 16:02:55 2018
     13// Update Count     : 114
    1414//
    1515
     
    2222        sout | '1' | '2' | '3';
    2323        sout | 1 | "" | 2 | "" | 3;
    24         sout;
     24        sout | nl;
    2525
    26         sout | "opening delimiters";
    27         sout | "x (" | 1 | nonl;
    28         sout | "x [" | 2 | nonl;
    29         sout | "x {" | 3 | nonl;
    30         sout | "x =" | 4 | nonl;
    31         sout | "x $" | 5 | nonl;
    32         sout | "x £" | 6 | nonl;
    33         sout | "x ¥" | 7 | nonl;
    34         sout | "x ¡" | 8 | nonl;
    35         sout | "x ¿" | 9 | nonl;
     26        sout | nlOff;
     27        sout | "opening delimiters" | nl;
     28        sout | "x (" | 1;
     29        sout | "x [" | 2;
     30        sout | "x {" | 3;
     31        sout | "x =" | 4;
     32        sout | "x $" | 5;
     33        sout | "x £" | 6;
     34        sout | "x ¥" | 7;
     35        sout | "x ¡" | 8;
     36        sout | "x ¿" | 9;
    3637        sout | "x «" | 10;
     38        sout | nl | nl;
    3739
    38         sout | "closing delimiters";
    39         sout | 1 | ", x" | nonl;
    40         sout | 2 | ". x" | nonl;
    41         sout | 3 | "; x" | nonl;
    42         sout | 4 | "! x" | nonl;
    43         sout | 5 | "? x" | nonl;
    44         sout | 6 | "% x" | nonl;
    45         sout | 7 | "¢ x" | nonl;
    46         sout | 8 | "» x" | nonl;
    47         sout | 9 | ") x" | nonl;
    48         sout | 10 | "] x" | nonl;
     40        sout | "closing delimiters" | nl;
     41        sout | 1 | ", x";
     42        sout | 2 | ". x";
     43        sout | 3 | "; x";
     44        sout | 4 | "! x";
     45        sout | 5 | "? x";
     46        sout | 6 | "% x";
     47        sout | 7 | "¢ x";
     48        sout | 8 | "» x";
     49        sout | 9 | ") x";
     50        sout | 10 | "] x";
    4951        sout | 11 | "} x";
     52        sout | nl | nl;
    5053
    51         sout | "opening/closing delimiters";
    52         sout | "x`" | 1 | "`x'" | 2 | nonl;
    53         sout | "'x\"" | 3 | "\"x:" | 4 | nonl;
    54         sout | ":x " | 5 | " x\t" | 6 | nonl;
    55         sout | "\tx\f" | 7 | "\fx\v" | 8 | nonl;
    56         sout | "\vx\n" | 9 | "\nx\r" | 10 | nonl;
     54        sout | "opening/closing delimiters" | nl;
     55        sout | "x`" | 1 | "`x'" | 2;
     56        sout | "'x\"" | 3 | "\"x:" | 4;
     57        sout | ":x " | 5 | " x\t" | 6;
     58        sout | "\tx\f" | 7 | "\fx\v" | 8;
     59        sout | "\vx\n" | 9 | "\nx\r" | 10;
    5760        sout | "\rx";
     61        sout | nl | nl;
    5862
     63        sout | nlOn;
    5964        sout | "override opening/closing delimiters";
    6065        sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4;
    61         sout;
     66        sout | nl;
    6267}
    6368
  • tests/io2.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 16:19:15 2018
    13 // Update Count     : 110
     12// Last Modified On : Fri Dec 21 08:20:14 2018
     13// Update Count     : 112
    1414//
    1515
     
    9696        sout | sepOn | 1 | 2 | 3 | sepOn;                                       // no separator at start/end of line
    9797        sout | 1 | sepOff | 2 | 3;                                                      // locally turn off implicit separator
    98         sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line
    99         sout | 1 | 2 | 3 | "\n\n" | sepOn;                                      // no separator at start of next line
     98        sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n' | nonl; // no separator at start/end of line
     99        sout | 1 | 2 | 3 | "\n\n" | sepOn | nonl;                                       // no separator at start of next line
    100100        sout | 1 | 2 | 3;
    101101        sout | nl;
     
    133133// Local Variables: //
    134134// tab-width: 4 //
    135 // compile-command: "cfa io2.cfa" //
     135// compile-command: "cfa -DIN_DIR=".in/" io2.cfa" //
    136136// End: //
  • tests/loopctrl.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Aug  8 18:32:59 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 08:14:44 2018
    13 // Update Count     : 76
     12// Last Modified On : Sun Dec 23 23:00:29 2018
     13// Update Count     : 79
    1414//
    1515
     
    3232S ?-=?( S & t, one_t ) { t.i -= 1; t.j -= 1; return t; }
    3333ofstream & ?|?( ofstream & os, S v ) { return os | '(' | v.i | v.j | ')'; }
    34 void & ?|?( ofstream & os, S v ) { (ofstream)(os | v); if ( getANL( os ) ) nl( os ); }
     34void & ?|?( ofstream & os, S v ) { (ofstream &)(os | v); nl( os ); }
    3535
    3636int main() {
     
    3838        while () { sout | "empty"; break; }                                     sout | nl;
    3939        do { sout | "empty"; break; } while ();                         sout | nl;
    40         for () { sout | "empty"; break; }                                       sout | nl;
     40        for () { sout | "empty"; break; }                                       sout | nl | nl;
    4141
    4242        for ( 0 ) { sout | "A"; }                                                       sout | "zero" | nl;
  • tests/polymorphism.cfa

    r84b4d607 r25cdca5  
    99// Author           : Rob Schluntz
    1010// Created On       : Tue Oct 17 12:19:48 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Oct 17 12:21:07 2017
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Dec 25 14:40:24 2018
     13// Update Count     : 3
    1414//
    1515
    1616#include <assert.h>
    1717#include <inttypes.h>
     18#include <fstream.hfa>
    1819
    1920forall(otype T)
     
    6162                int y = 456;
    6263                int z = f(x, y);
    63                 printf("%d %d %d\n", x, y, z);
     64                sout | x | y | z;
    6465        }
    65 
    6666        {
    6767                // explicitly specialize function
    6868                int (*f)(int) = ident;
    6969                ((int(*)(int))ident);
    70                 printf("%d %d\n", f(5), ((int(*)(int))ident)(5));
     70                sout | f(5) | ((int(*)(int))ident)(5);
    7171        }
    72 
    7372        {
    7473                // test aggregates with polymorphic members
     
    10099
    101100                void print(x_type x) {
    102                         printf("%"PRIu32"\n", x);
     101                        sout | x;
    103102                }
    104103
    105104                void print(y_type y) {
    106                         printf("%"PRIu64"\n", y);
     105                        sout | y;
    107106                }
    108107
  • tests/pybin/tools.py

    r84b4d607 r25cdca5  
    7979def diff( lhs, rhs ):
    8080        # diff the output of the files
    81         diff_cmd = ("diff --ignore-all-space --text "
    82                                 "--ignore-blank-lines "
     81        diff_cmd = ("diff --text "
     82#                               "--ignore-all-space "
     83#                               "--ignore-blank-lines "
    8384                                "--old-group-format='\t\tmissing lines :\n"
    8485                                "%%<' \\\n"
  • tests/raii/dtor-early-exit.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed Aug 17 08:26:25 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:05:24 2018
    13 // Update Count     : 9
     12// Last Modified On : Fri Dec 21 08:45:19 2018
     13// Update Count     : 10
    1414//
    1515
     
    7171                }
    7272        }
    73         sout;
     73        sout | nl;
    7474        for (int i = 0; i < 10; i++) {
    7575                switch(10) {
  • tests/references.cfa

    r84b4d607 r25cdca5  
    99// Author           : Rob Schluntz
    1010// Created On       : Wed Aug 23 16:11:50 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 23 16:12:03
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Dec 25 14:31:48 2018
     13// Update Count     : 11
    1414//
    1515
     16#include <fstream.hfa>
     17
    1618struct Y { int i; };
    17 void ?{}(Y & y) { printf("Default constructing a Y\n"); }
    18 void ?{}(Y & y, Y other) { printf("Copy constructing a Y\n"); }
    19 void ^?{}(Y & y) { printf("Destructing a Y\n"); }
    20 Y ?=?(Y & y, Y other) { printf("Assigning a Y\n"); return y; }
    21 void ?{}(Y & y, int i) { printf("Value constructing a Y %d\n", i); y.i = i; }
     19void ?{}( Y & y ) { sout | "Default constructing a Y"; }
     20void ?{}( Y & y, Y other ) { sout | "Copy constructing a Y"; }
     21void ^?{}( Y & y ) { sout | "Destructing a Y"; }
     22Y ?=?( Y & y, Y other ) { sout | "Assigning a Y"; return y; }
     23void ?{}( Y & y, int i ) { sout | "Value constructing a Y" | i; y.i = i; }
    2224
    2325struct X { Y & r; Y y; };
    24 void ?{}(X & x) {
     26void ?{}( X & x ) {
    2527        // ensure that r is not implicitly constructed
    2628}
    27 void ?{}(X & x, X other) {
     29void ?{}( X & x, X other ) {
    2830        // ensure that r is not implicitly constructed
    2931}
    30 void ^?{}(X & x) {
     32void ^?{}( X & x ) {
    3133        // ensure that r is not implicitly destructed
    3234}
    33 X ?=?(X & x, X other) { return x; }
     35X ?=?( X & x, X other ) { return x; }
    3436
    3537// ensure that generated functions do not implicitly operate on references
     
    4850        int x = 123456, x2 = 789, *p1 = &x, **p2 = &p1, ***p3 = &p2,
    4951                &r1 = x,    &&r2 = r1,   &&&r3 = r2;
    50         ***p3 = 3;                          // change x
    51         **p3 = &x;                          // change p1
    52         *p3 = &p1;                          // change p2
    53         int y = 0, z = 11, & ar[3] = { x, y, z };    // initialize array of references
    54         // &ar[1] = &z;                        // change reference array element
    55         // typeof( ar[1] ) p = 3;              // is int, i.e., the type of referenced object
    56         // typeof( &ar[1] ) q = &x;            // is int *, i.e., the type of pointer
     52        ***p3 = 3;                                                                                      // change x
     53        **p3 = &x;                                                                                      // change p1
     54        *p3 = &p1;                                                                                      // change p2
     55        int y = 0, z = 11, & ar[3] = { x, y, z };                       // initialize array of references
     56                                                                                                                // &ar[1] = &z;                        // change reference array element
     57                                                                                                                // typeof( ar[1] ) p = 3;              // is int, i.e., the type of referenced object
     58                                                                                                                // typeof( &ar[1] ) q = &x;            // is int *, i.e., the type of pointer
    5759        // _Static_assert( sizeof( ar[1] ) == sizeof( int ), "Array type should be int." );   // is true, i.e., the size of referenced object
    5860        // _Static_assert( sizeof( &ar[1] ) == sizeof( int *), "Address of array should be int *." ); // is true, i.e., the size of a reference
    5961
    60         ((int*&)&r3) = &x;                  // change r1, (&*)**r3
     62        ((int*&)&r3) = &x;                                                                      // change r1, (&*)**r3
    6163        x = 3;
    6264        // test that basic reference properties are true - r1 should be an alias for x
    63         printf("%d %d %d\n", x, r1, &x == &r1);
     65        sout | x | r1 | &x == &r1;
    6466        r1 = 12;
    65         printf("%d %d %d\n", x, r1, &x == &r1);
     67        sout | x | r1 | &x == &r1;
    6668
    6769        // test that functions using basic references work
    68         printf("%d %d %d %d\n", toref(&x), toref(p1), toptr(r1) == toptr(x), toptr(r1) == &x);
     70        sout | toref( &x ) | toref( p1 ) | toptr( r1 ) == toptr( x ) | toptr( r1 ) == &x;
    6971
    7072        changeRef( x );
    7173        changeRef( y );
    7274        changeRef( z );
    73         printf("%d %d %d\n", x, y, z);
     75        sout | x | y | z;
    7476        changeRef( r1 );
    75         printf("%d %d\n", r1, x);
     77        sout | r1 | x;
    7678
    77         r3 = 6;                               // change x, ***r3
    78         printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
    79         &r3 = &x2;                            // change r1 to refer to x2, (&*)**r3
    80         r3 = 999;                             // modify x2
    81         printf("x = %d ; x2 = %d\n", x, x2);  // check that x2 was changed
    82         ((int**&)&&r3) = p2;                  // change r2, (&(&*)*)*r3, ensure explicit cast to reference works
    83         r3 = 12345;                           // modify x
    84         printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
    85         &&&r3 = p3;                           // change r3 to p3, (&(&(&*)*)*)r3
    86         ((int&)r3) = 22222;                   // modify x, ensure explicit cast to reference works
    87         printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     79        r3 = 6;                                                                                         // change x, ***r3
     80        sout | "x = " | x | " ; x2 = " | x2;                            // check that x was changed
     81        &r3 = &x2;                                                                                      // change r1 to refer to x2, (&*)**r3
     82        r3 = 999;                                                                                       // modify x2
     83        sout | "x = " | x | " ; x2 = " | x2;                            // check that x2 was changed
     84        ((int**&)&&r3) = p2;                                                            // change r2, (&(&*)*)*r3, ensure explicit cast to reference works
     85        r3 = 12345;                                                                                     // modify x
     86        sout | "x = " | x | " ; x2 = " | x2;                            // check that x was changed
     87        &&&r3 = p3;                                                                                     // change r3 to p3, (&(&(&*)*)*)r3
     88        ((int&)r3) = 22222;                                                                     // modify x, ensure explicit cast to reference works
     89        sout | "x = " | x | " ; x2 = " | x2;                                    // check that x was changed
    8890
    8991        // test that reference members are not implicitly constructed/destructed/assigned
     
    102104                struct S { double x, y; };
    103105                void f( int & i, int & j, S & s, int v[] ) {
    104                         printf("%d %d { %g, %g }, [%d, %d, %d]\n", i, j, s.[x, y], v[0], v[1], v[2]);
     106                        sout | i | j | "{ " | s.[x, y] | " }," | "[" | v[0] | "," | v[1] | "," | v[2] | "]";
    105107                }
    106                 void g(int & i) { printf("%d\n", i); }
    107                 void h(int &&& i) { printf("%d\n", i); }
     108                void g(int & i) { sout | i; }
     109                void h(int &&& i) { sout | i; }
    108110
    109                 int &&& r = 3;  // rvalue to reference
     111                int &&& r = 3;                                                                  // rvalue to reference
    110112                int i = r;
    111                 printf("%d %d\n", i, r);  // both 3
     113                sout | i | r;                                                                   // both 3
    112114
    113                 g( 3 );          // rvalue to reference
    114                 h( (int &&&)3 ); // rvalue to reference
     115                g( 3 );                                                                                 // rvalue to reference
     116                h( (int &&&)3 );                                                                // rvalue to reference
    115117
    116118                int a = 5, b = 4;
  • tests/searchsort.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Thu Feb  4 18:17:50 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  5 08:18:42 2018
    13 // Update Count     : 106
     12// Last Modified On : Thu Dec 20 22:49:46 2018
     13// Update Count     : 108
    1414//
    1515
     
    2121
    2222int main( void ) {
    23         const unsigned int size = 10;
     23        const int size = 10;
    2424        int iarr[size];
    2525
    2626        sout | nlOff;                                                                           // turn off auto newline
    2727
    28         for ( i; 0u ~ size ) {
     28        for ( i; 0 ~ size ) {
    2929                iarr[i] = size - i;
    3030                sout | iarr[i] | ", ";
    3131        } // for
    32         sout | nl;
     32        sout | nl | nl;
    3333
    3434        // ascending sort/search by changing < to >
    3535        qsort( iarr, size );
    36         for ( i; 0u ~ size ) {
     36        for ( i; 0 ~ size ) {
    3737                sout | iarr[i] | ", ";
    3838        } // for
    3939        sout | nl;
    40         for ( i; 0u ~ size ) {          // C version
     40        for ( i; 0 ~ size ) {           // C version
    4141                int key = size - i;
    4242                int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
     
    4545        sout | nl;
    4646
    47         for ( i; 0u ~ size ) {
     47        for ( i; 0 ~ size ) {
    4848                int * v = bsearch( size - i, iarr, size );
    4949                sout | size - i | ':' | *v | ", ";
    5050        } // for
    5151        sout | nl;
    52         for ( i; 0u ~ size ) {
     52        for ( i; 0 ~ size ) {
    5353                unsigned int posn = bsearch( size - i, iarr, size );
    5454                sout | size - i | ':' | iarr[posn] | ", ";
    5555        } // for
    56         sout | nl;
     56        sout | nl | nl;
    5757
    5858        // descending sort/search by changing < to >
     
    6363        sout | nl;
    6464        {
    65                 int ?<?( int x, int y ) { return x > y; }
    66                 qsort( iarr, size );
    67                 for ( i; 0u ~ size ) {
     65                // redefinition of ?<? can't overlap the loop controls:
     66                {
     67                        int (*?<?)(int, int) = ?>?;
     68                        qsort( iarr, size );
     69                }
     70                for ( i; 0 ~ size ) {
    6871                        sout | iarr[i] | ", ";
    6972                } // for
    7073                sout | nl;
    71                 for ( i; 0u ~ size ) {
     74                for ( i; 0 ~ size ) {
     75                        int (*?<?)(int, int) = ?>?;
    7276                        int * v = bsearch( size - i, iarr, size );
    7377                        sout | size - i | ':' | *v | ", ";
    7478                } // for
    7579                sout | nl;
    76                 for ( i; 0u ~ size ) {
     80                for ( i; 0 ~ size ) {
     81                        int (*?<?)(int, int) = ?>?;
    7782                        unsigned int posn = bsearch( size - i, iarr, size );
    7883                        sout | size - i | ':' | iarr[posn] | ", ";
    7984                } // for
    8085        }
    81         sout | nl;
     86        sout | nl | nl;
    8287
    8388        double darr[size];
    84         for ( i; 0u ~ size ) {
     89        for ( i; 0 ~ size ) {
    8590                darr[i] = size - i + 0.5;
    8691                sout | darr[i] | ", ";
     
    8893        sout | nl;
    8994        qsort( darr, size );
    90         for ( i; 0u ~ size ) {
     95        for ( i; 0 ~ size ) {
    9196                sout | darr[i] | ", ";
    9297        } // for
    9398        sout | nl;
    94         for ( i; 0u ~ size ) {
     99        for ( i; 0 ~ size ) {
    95100                double * v = bsearch( size - i + 0.5, darr, size );
    96101                sout | size - i + 0.5 | ':' | *v | ", ";
    97102        } // for
    98103        sout | nl;
    99         for ( i; 0u ~ size ) {
     104        for ( i; 0 ~ size ) {
    100105                unsigned int posn = bsearch( size - i + 0.5, darr, size );
    101106                sout | size - i + 0.5 | ':' | darr[posn] | ", ";
    102107        } // for
    103         sout | nl;
     108        sout | nl | nl;
    104109
    105110        struct S { int i, j; } sarr[size];
    106111        int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; }
    107112        ofstream & ?|?( ofstream & os, S v ) { return os | v.i | ' ' | v.j; }
    108         for ( i; 0u ~ size ) {
     113        for ( i; 0 ~ size ) {
    109114                sarr[i].i = size - i;
    110115                sarr[i].j = size - i + 1;
     
    113118        sout | nl;
    114119        qsort( sarr, size );
    115         for ( i; 0u ~ size ) {
     120        for ( i; 0 ~ size ) {
    116121                sout | sarr[i] | ", ";
    117122        } // for
    118123        sout | nl;
    119         for ( i; 0u ~ size ) {
     124        for ( i; 0 ~ size ) {
    120125                S temp = { size - i, size - i + 1 };
    121126                S * v = bsearch( temp, sarr, size );
     
    123128        } // for
    124129        sout | nl;
    125         for ( i; 0u ~ size ) {
     130        for ( i; 0 ~ size ) {
    126131                S temp = { size - i, size - i + 1 };
    127132                unsigned int posn = bsearch( temp, sarr, size );
    128133                sout | temp | ':' | sarr[posn] | ", ";
    129134        } // for
    130         sout | nl;
     135        sout | nl | nl;
    131136        {
    132                 unsigned int getKey( const S & s ) { return s.j; }
    133                 for ( i; 0u ~ size ) {
     137                int getKey( const S & s ) { return s.j; }
     138                for ( i; 0 ~ size ) {
    134139                        sout | sarr[i] | ", ";
    135140                } // for
    136141                sout | nl;
    137                 for ( i; 0u ~ size ) {
     142                for ( i; 0 ~ size ) {
    138143                        S * v = bsearch( size - i + 1, sarr, size );
    139144                        sout | size - i + 1 | ':' | *v | ", ";
    140145                } // for
    141146                sout | nl;
    142                 for ( i; 0u ~ size ) {
     147                for ( i; 0 ~ size ) {
    143148                        unsigned int posn = bsearch( size - i + 1, sarr, size );
    144149                        sout | size - i + 1 | ':' | sarr[posn] | ", ";
    145150                } // for
    146                 sout | nl;
     151                sout | nl | nl;
    147152        }
    148153} // main
  • tests/sum.cfa

    r84b4d607 r25cdca5  
    1111// Created On       : Wed May 27 17:56:53 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Dec 11 21:50:41 2018
    14 // Update Count     : 285
     13// Last Modified On : Sun Dec 23 23:00:38 2018
     14// Update Count     : 287
    1515//
    1616
     
    9393        S ?++( S & t ) { S temp = t; t += (S){1}; return temp; }
    9494        ofstream & ?|?( ofstream & os, S v ) { return os | v.i | v.j; }
    95         void ?|?( ofstream & os, S v ) { (ofstream)(os | v); if ( getANL( os ) ) nl( os ); }
     95        void ?|?( ofstream & os, S v ) { (ofstream &)(os | v); nl( os ); }
    9696
    9797        S s = (S){0}, a[size], v = { low, low };
  • tests/swap.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 10:17:40 2018
    13 // Update Count     : 74
     12// Last Modified On : Sun Dec 23 23:00:49 2018
     13// Update Count     : 77
    1414//
    1515
     
    8585        struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 };
    8686        ofstream & ?|?( ofstream & os, S s ) { return os | s.i | s.j; }
     87        void ?|?( ofstream & os, S s ) { (ofstream &)(os | s.i | s.j); nl( os ); }
    8788        sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap " | nonl;
    8889        swap( s1, s2 );
  • tests/time.cfa

    r84b4d607 r25cdca5  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:44:03 2018
    13 // Update Count     : 22
     12// Last Modified On : Thu Dec 20 23:09:21 2018
     13// Update Count     : 23
    1414//
    1515
     
    3030        sout | d1 == 7`s | d1 == d2 | d1 == 0;
    3131        sout | div( 7`s, 2`s );
     32        sout | nl;
    3233
    3334        Time t = { 1970, 1, 2, 0, 0, 0, 10_000_000 };
     
    4647        Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 };
    4748        sout | t2 | t2.tv | nl | t3 | t3.tv;
     49        sout | nl;
    4850
    4951        // Clock Newfoundland = { -3.5`h }, PST = { -8`h };     // distance from GMT (UTC)
     
    5355        //       | "local nsec" | getTimeNsec()
    5456        //       | "PST" | PST();                                                               // getTime short form
    55         // sout;
     57        // sout | nl;
    5658
    5759        // http://en.cppreference.com/w/cpp/chrono/duration/operator_arith4
  • tests/withStatement.cfa

    r84b4d607 r25cdca5  
    99// Author           : Rob Schluntz
    1010// Created On       : Mon Dec 04 17:41:45 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Dec 04 17:45:07 2017
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Dec 24 19:08:18 2018
     13// Update Count     : 5
    1414//
    1515
     16#include <fstream.hfa>
     17
    1618struct S {
    17   int i;
    18   // dynamically allocated member ensures ctor/dtors are called correctly on temporaries
    19   int * ptr;
     19        int i;
     20        // dynamically allocated member ensures ctor/dtors are called correctly on temporaries
     21        int * ptr;
    2022};
    2123
    2224// with clause on reference parameter
    23 void ?{}(S & this, int n) with(this) {
    24   i = n;
    25   ptr = (int *)malloc(sizeof(int));
     25void ?{}( S & this, int n ) with( this ) {
     26        i = n;
     27        ptr = (int *)malloc( sizeof(int) );
    2628}
    2729
    28 void ?{}(S & this) {
    29   this{ 0 };
     30void ?{}( S & this ) {
     31        this{ 0 };
    3032}
    3133
    32 void ?{}(S & this, S other) {
    33   this{ other.i };
     34void ?{}( S & this, S other ) {
     35        this{ other.i };
    3436}
    3537
    36 S ?=?(S & this, S other) with(this) {
    37   i = other.i;
    38   *ptr = *other.ptr;
    39   return this;
     38S ?=?( S & this, S other ) with( this ) {
     39        i = other.i;
     40        *ptr = *other.ptr;
     41        return this;
    4042}
    4143
    42 void ^?{}(S & this) with(this) {
    43   free(ptr);
     44void ^?{}( S & this ) with( this ) {
     45        free( ptr );
    4446}
    4547
    4648struct S2 {
    47   S s;
     49        S s;
    4850};
    4951
    50 void ?{}(S2 & this, int n) {
    51   (this.s){ n };
     52void ?{}( S2 & this, int n ) {
     53        (this.s){ n };
    5254}
    5355
    54 forall(otype T)
     56forall( otype T )
    5557struct Box {
    56   T x;
     58        T x;
    5759};
    5860
    59 forall(otype T)
    60 void ?{}(Box(T) & this) with(this) { // with clause in polymorphic function
    61   x{};
     61forall( otype T )
     62void ?{}( Box(T) & this ) with( this ) { // with clause in polymorphic function
     63        x{};
    6264}
    6365
    64 void print(int i) { printf("%d", i); }
     66void print( int i ) { sout | i; }
    6567
    66 forall(otype T | { void print(T); })
    67 void foo(T t) {
    68   Box(T) b = { t };
    69   with(b) {  // with statement in polymorphic function
    70     print(x);
    71     printf("\n");
    72   }
     68forall( otype T | { void print( T ); })
     69void foo( T t ) {
     70        Box( T ) b = { t };
     71        with( b ) {  // with statement in polymorphic function
     72                print( x );
     73        }
    7374}
    7475
    7576// ensure with-statement temporary generation works correctly
    7677S mk() {
    77   printf("called mk\n");
    78   return (S) { 444 };
     78        sout | "called mk";
     79        return (S){ 444 };
    7980}
    8081
    8182// ensure with-statement temporary generation with reference-returning functions works correctly
    8283S & ref() {
    83   static S var = { 123456789 };
    84   return var;
     84        static S var = { 123456789 };
     85        return var;
    8586}
    8687
    8788int main() {
    88   S2 s2 = { 12345 };
    89   with (s2) {
    90     with(s) { // with s2.s
    91       printf("%d %d %d\n", i, s.i, s2.s.i);
    92       foo(i);  // s.i
    93       with(mk()) {
    94         printf("%d %d %d\n", i, i, i);
    95         with(ref()) {
    96           printf("%d %d %d\n", i, i, i);
    97         } // with ref()
    98         with(ref()) {
    99           printf("%d %d %d\n", i, i, i);
    100         } // with ref()
    101       } // with mk()
    102     } // with s
    103   } // with s2
     89        S2 s2 = { 12345 };
     90        with ( s2) {
     91                with( s ) { // with s2.s
     92                        sout | i | s.i | s2.s.i;
     93                        foo( i );  // s.i
     94                        with( mk()) {
     95                                sout | i | i | i;
     96                                with( ref()) {
     97                                        sout | i | i | i;
     98                                } // with ref()
     99                                with( ref()) {
     100                                        sout | i | i | i;
     101                                } // with ref()
     102                        } // with mk()
     103                } // with s
     104        } // with s2
    104105}
    105106
Note: See TracChangeset for help on using the changeset viewer.