Changeset 25cdca5 for libcfa


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

Location:
libcfa/src
Files:
7 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
Note: See TracChangeset for help on using the changeset viewer.