Changeset 7bc4e6b


Ignore:
Timestamp:
Aug 24, 2017, 8:53:28 AM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
a4d9b77
Parents:
1efa1e1
Message:

change iostream to use references, and update affected tests

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream

    r1efa1e1 r7bc4e6b  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  9 16:42:47 2017
    13 // Update Count     : 131
     12// Last Modified On : Thu Aug 24 08:14:29 2017
     13// Update Count     : 133
    1414//
    1515
     
    117117}; // readable
    118118
    119 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, char * );
     119forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, char & );
    120120
    121 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, short int * );
    122 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned short int * );
    123 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, int * );
    124 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned int * );
    125 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long int * );
    126 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long long int * );
    127 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long int * );
    128 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long long int * );
     121forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, short int & );
     122forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned short int & );
     123forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, int & );
     124forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned int & );
     125forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long int & );
     126forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long long int & );
     127forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long int & );
     128forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned long long int & );
    129129
    130 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float * );
    131 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double * );
    132 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double * );
     130forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float & );
     131forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double & );
     132forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double & );
    133133
    134 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float _Complex * );
    135 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double _Complex * );
    136 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double _Complex * );
     134forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, float _Complex & );
     135forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, double _Complex & );
     136forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, long double _Complex & );
    137137
    138138struct _Istream_cstrUC { char * s; };
  • src/libcfa/iostream.c

    r1efa1e1 r7bc4e6b  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  9 16:46:51 2017
    13 // Update Count     : 401
     12// Last Modified On : Thu Aug 24 08:41:53 2017
     13// Update Count     : 405
    1414//
    1515
     
    271271
    272272forall( dtype istype | istream( istype ) )
    273 istype * ?|?( istype * is, char * c ) {
    274         fmt( is, "%c", c );
    275         return is;
    276 } // ?|?
    277 
    278 forall( dtype istype | istream( istype ) )
    279 istype * ?|?( istype * is, short int * si ) {
    280         fmt( is, "%hd", si );
    281         return is;
    282 } // ?|?
    283 
    284 forall( dtype istype | istream( istype ) )
    285 istype * ?|?( istype * is, unsigned short int * usi ) {
    286         fmt( is, "%hu", usi );
    287         return is;
    288 } // ?|?
    289 
    290 forall( dtype istype | istream( istype ) )
    291 istype * ?|?( istype * is, int * i ) {
    292         fmt( is, "%d", i );
    293         return is;
    294 } // ?|?
    295 
    296 forall( dtype istype | istream( istype ) )
    297 istype * ?|?( istype * is, unsigned int * ui ) {
    298         fmt( is, "%u", ui );
    299         return is;
    300 } // ?|?
    301 
    302 forall( dtype istype | istream( istype ) )
    303 istype * ?|?( istype * is, long int * li ) {
    304         fmt( is, "%ld", li );
    305         return is;
    306 } // ?|?
    307 
    308 forall( dtype istype | istream( istype ) )
    309 istype * ?|?( istype * is, unsigned long int * ulli ) {
    310         fmt( is, "%lu", ulli );
    311         return is;
    312 } // ?|?
    313 
    314 forall( dtype istype | istream( istype ) )
    315 istype * ?|?( istype * is, long long int * lli ) {
    316         fmt( is, "%lld", lli );
    317         return is;
    318 } // ?|?
    319 
    320 forall( dtype istype | istream( istype ) )
    321 istype * ?|?( istype * is, unsigned long long int * ulli ) {
    322         fmt( is, "%llu", ulli );
    323         return is;
    324 } // ?|?
    325 
    326 
    327 forall( dtype istype | istream( istype ) )
    328 istype * ?|?( istype * is, float * f ) {
    329         fmt( is, "%f", f );
    330         return is;
    331 } // ?|?
    332 
    333 forall( dtype istype | istream( istype ) )
    334 istype * ?|?( istype * is, double * d ) {
    335         fmt( is, "%lf", d );
    336         return is;
    337 } // ?|?
    338 
    339 forall( dtype istype | istream( istype ) )
    340 istype * ?|?( istype * is, long double * ld ) {
    341         fmt( is, "%Lf", ld );
    342         return is;
    343 } // ?|?
    344 
    345 
    346 forall( dtype istype | istream( istype ) )
    347 istype * ?|?( istype * is, float _Complex * fc ) {
     273istype * ?|?( istype * is, char & c ) {
     274        fmt( is, "%c", &c );                                                            // must pass pointer through varg to fmt
     275        return is;
     276} // ?|?
     277
     278forall( dtype istype | istream( istype ) )
     279istype * ?|?( istype * is, short int & si ) {
     280        fmt( is, "%hd", &si );
     281        return is;
     282} // ?|?
     283
     284forall( dtype istype | istream( istype ) )
     285istype * ?|?( istype * is, unsigned short int & usi ) {
     286        fmt( is, "%hu", &usi );
     287        return is;
     288} // ?|?
     289
     290forall( dtype istype | istream( istype ) )
     291istype * ?|?( istype * is, int & i ) {
     292        fmt( is, "%d", &i );
     293        return is;
     294} // ?|?
     295
     296forall( dtype istype | istream( istype ) )
     297istype * ?|?( istype * is, unsigned int & ui ) {
     298        fmt( is, "%u", &ui );
     299        return is;
     300} // ?|?
     301
     302forall( dtype istype | istream( istype ) )
     303istype * ?|?( istype * is, long int & li ) {
     304        fmt( is, "%ld", &li );
     305        return is;
     306} // ?|?
     307
     308forall( dtype istype | istream( istype ) )
     309istype * ?|?( istype * is, unsigned long int & ulli ) {
     310        fmt( is, "%lu", &ulli );
     311        return is;
     312} // ?|?
     313
     314forall( dtype istype | istream( istype ) )
     315istype * ?|?( istype * is, long long int & lli ) {
     316        fmt( is, "%lld", &lli );
     317        return is;
     318} // ?|?
     319
     320forall( dtype istype | istream( istype ) )
     321istype * ?|?( istype * is, unsigned long long int & ulli ) {
     322        fmt( is, "%llu", &ulli );
     323        return is;
     324} // ?|?
     325
     326
     327forall( dtype istype | istream( istype ) )
     328istype * ?|?( istype * is, float & f ) {
     329        fmt( is, "%f", &f );
     330        return is;
     331} // ?|?
     332
     333forall( dtype istype | istream( istype ) )
     334istype * ?|?( istype * is, double & d ) {
     335        fmt( is, "%lf", &d );
     336        return is;
     337} // ?|?
     338
     339forall( dtype istype | istream( istype ) )
     340istype * ?|?( istype * is, long double & ld ) {
     341        fmt( is, "%Lf", &ld );
     342        return is;
     343} // ?|?
     344
     345
     346forall( dtype istype | istream( istype ) )
     347istype * ?|?( istype * is, float _Complex & fc ) {
    348348        float re, im;
    349349        fmt( is, "%g%gi", &re, &im );
    350         *fc = re + im * _Complex_I;
    351         return is;
    352 } // ?|?
    353 
    354 forall( dtype istype | istream( istype ) )
    355 istype * ?|?( istype * is, double _Complex * dc ) {
     350        fc = re + im * _Complex_I;
     351        return is;
     352} // ?|?
     353
     354forall( dtype istype | istream( istype ) )
     355istype * ?|?( istype * is, double _Complex & dc ) {
    356356        double re, im;
    357357        fmt( is, "%lf%lfi", &re, &im );
    358         *dc = re + im * _Complex_I;
    359         return is;
    360 } // ?|?
    361 
    362 forall( dtype istype | istream( istype ) )
    363 istype * ?|?( istype * is, long double _Complex * ldc ) {
     358        dc = re + im * _Complex_I;
     359        return is;
     360} // ?|?
     361
     362forall( dtype istype | istream( istype ) )
     363istype * ?|?( istype * is, long double _Complex & ldc ) {
    364364        long double re, im;
    365365        fmt( is, "%Lf%Lfi", &re, &im );
    366         *ldc = re + im * _Complex_I;
     366        ldc = re + im * _Complex_I;
    367367        return is;
    368368} // ?|?
  • src/libcfa/rational

    r1efa1e1 r7bc4e6b  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Fri Jul  7 09:34:33 2017
    15 // Update Count     : 93
     14// Last Modified On : Wed Aug 23 22:35:09 2017
     15// Update Count     : 95
    1616//
    1717
     
    135135// I/O
    136136forall( otype RationalImpl | arithmetic( RationalImpl ) )
    137 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    138 istype * ?|?( istype *, Rational(RationalImpl) * );
     137forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl & ); } )
     138istype * ?|?( istype *, Rational(RationalImpl) & );
    139139
    140140forall( otype RationalImpl | arithmetic( RationalImpl ) )
  • src/libcfa/rational.c

    r1efa1e1 r7bc4e6b  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 16 18:35:36 2017
    13 // Update Count     : 150
     12// Last Modified On : Wed Aug 23 22:38:48 2017
     13// Update Count     : 154
    1414//
    1515
     
    3434
    3535forall( otype RationalImpl | arithmetic( RationalImpl ) )
    36 static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) {
    37         if ( *d == (RationalImpl){0} ) {
     36static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) {
     37        if ( d == (RationalImpl){0} ) {
    3838                serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
    3939                exit( EXIT_FAILURE );
    4040        } // exit
    41         if ( *d < (RationalImpl){0} ) { *d = -*d; *n = -*n; } // move sign to numerator
    42         return gcd( abs( *n ), *d );                                            // simplify
     41        if ( d < (RationalImpl){0} ) { d = -d; n = -n; }        // move sign to numerator
     42        return gcd( abs( n ), d );                                                      // simplify
    4343} // Rationalnumber::simplify
    4444
     
    5858forall( otype RationalImpl | arithmetic( RationalImpl ) )
    5959void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d ) {
    60         RationalImpl t = simplify( &n, &d );                            // simplify
     60        RationalImpl t = simplify( n, d );                                      // simplify
    6161        r.numerator = n / t;
    6262        r.denominator = d / t;
     
    9595RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
    9696        RationalImpl prev = r.denominator;
    97         RationalImpl t = simplify( &r.numerator, &d );                  // simplify
     97        RationalImpl t = simplify( r.numerator, d );                    // simplify
    9898        r.numerator = r.numerator / t;
    9999        r.denominator = d / t;
     
    228228
    229229forall( otype RationalImpl | arithmetic( RationalImpl ) )
    230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    231 istype * ?|?( istype * is, Rational(RationalImpl) * r ) {
     230forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl & ); } )
     231istype * ?|?( istype * is, Rational(RationalImpl) & r ) {
    232232        RationalImpl t;
    233         is | &(r->numerator) | &(r->denominator);
    234         t = simplify( &(r->numerator), &(r->denominator) );
    235         r->numerator /= t;
    236         r->denominator /= t;
     233        is | r.numerator | r.denominator;
     234        t = simplify( r.numerator, r.denominator );
     235        r.numerator /= t;
     236        r.denominator /= t;
    237237        return is;
    238238} // ?|?
  • src/tests/io.c

    r1efa1e1 r7bc4e6b  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 23:26:12 2017
    13 // Update Count     : 78
     12// Last Modified On : Wed Aug 23 21:27:50 2017
     13// Update Count     : 79
    1414//
    1515
     
    8989
    9090        sout | "input bacis types" | endl;
    91         &in | &c                                                                                        // character
    92                 | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli     // integral
    93                 | &f | &d | &ld                                                                 // floating point
    94                 | &fc | &dc | &ldc                                                              // floating-point complex
     91        &in | c                                                                                         // character
     92                | si | usi | i | ui | li | uli | lli | ulli             // integral
     93                | f | d | ld                                                                    // floating point
     94                | fc | dc | ldc                                                                 // floating-point complex
    9595                | cstr( s1 ) | cstr( s2, size );                                // C string, length unchecked and checked
    9696        sout | endl;
  • src/tests/rational.c

    r1efa1e1 r7bc4e6b  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 17 15:46:35 2017
    13 // Update Count     : 65
     12// Last Modified On : Wed Aug 23 21:40:11 2017
     13// Update Count     : 66
    1414//
    1515
     
    9292        sout | x | endl;
    9393
    94         sin | &a | &b;
     94        sin | a | b;
    9595        sout | a | b | endl;
    9696} // main
  • src/tests/vector/vector_test.c

    r1efa1e1 r7bc4e6b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Apr 27 17:31:27 2016
    13 // Update Count     : 18
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug 24 08:15:38 2017
     13// Update Count     : 19
    1414//
    1515
     
    2727        sout | "enter N elements and C-d on a separate line:" | endl;
    2828        for ( ;; ) {
    29                 sin | &num;
     29                sin | num;
    3030          if ( fail( sin ) || eof( sin ) ) break;
    3131                append( &vec, num );
Note: See TracChangeset for help on using the changeset viewer.