Ignore:
Timestamp:
Jun 2, 2018, 10:00:29 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
428bef8
Parents:
d56cc219
Message:

more push/pop updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/rational

    rd56cc219 r3ce0d440  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Wed Dec  6 23:12:53 2017
    15 // Update Count     : 97
     14// Last Modified On : Sat Jun  2 09:10:01 2018
     15// Update Count     : 105
    1616//
    1717
     
    4646// implementation
    4747
    48 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    49 struct Rational {
    50         RationalImpl numerator, denominator;                            // invariant: denominator > 0
    51 }; // Rational
     48forall( otype RationalImpl | arithmetic( RationalImpl ) ) {
     49        struct Rational {
     50                RationalImpl numerator, denominator;                    // invariant: denominator > 0
     51        }; // Rational
    5252
    53 // constructors
     53        // constructors
    5454
    55 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    56 void ?{}( Rational(RationalImpl) & r );
     55        void ?{}( Rational(RationalImpl) & r );
     56        void ?{}( Rational(RationalImpl) & r, RationalImpl n );
     57        void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d );
     58        void ?{}( Rational(RationalImpl) & r, zero_t );
     59        void ?{}( Rational(RationalImpl) & r, one_t );
    5760
    58 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    59 void ?{}( Rational(RationalImpl) & r, RationalImpl n );
     61        // numerator/denominator getter
    6062
    61 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    62 void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d );
     63        RationalImpl numerator( Rational(RationalImpl) r );
     64        RationalImpl denominator( Rational(RationalImpl) r );
     65        [ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    6366
    64 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    65 void ?{}( Rational(RationalImpl) & r, zero_t );
     67        // numerator/denominator setter
    6668
    67 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    68 void ?{}( Rational(RationalImpl) & r, one_t );
     69        RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
     70        RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
    6971
    70 // numerator/denominator getter
     72        // comparison
    7173
    72 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    73 RationalImpl numerator( Rational(RationalImpl) r );
     74        int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     75        int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     76        int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     77        int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     78        int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     79        int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    7480
    75 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    76 RationalImpl denominator( Rational(RationalImpl) r );
     81        // arithmetic
    7782
    78 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    79 [ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
     83        Rational(RationalImpl) +?( Rational(RationalImpl) r );
     84        Rational(RationalImpl) -?( Rational(RationalImpl) r );
     85        Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     86        Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     87        Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     88        Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    8089
    81 // numerator/denominator setter
     90        // I/O
     91        forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )
     92        istype & ?|?( istype &, Rational(RationalImpl) & );
    8293
    83 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    84 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
    85 
    86 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    87 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
    88 
    89 // comparison
    90 
    91 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    92 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    93 
    94 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    95 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    96 
    97 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    98 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    99 
    100 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    101 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    102 
    103 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    104 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    105 
    106 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    107 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    108 
    109 // arithmetic
    110 
    111 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    112 Rational(RationalImpl) +?( Rational(RationalImpl) r );
    113 
    114 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    115 Rational(RationalImpl) -?( Rational(RationalImpl) r );
    116 
    117 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    118 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    119 
    120 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    121 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    122 
    123 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    124 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    125 
    126 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    127 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     94        forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
     95        ostype & ?|?( ostype &, Rational(RationalImpl ) );
     96} // distribution
    12897
    12998// conversion
     
    133102Rational(RationalImpl) narrow( double f, RationalImpl md );
    134103
    135 // I/O
    136 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    137 forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )
    138 istype & ?|?( istype &, Rational(RationalImpl) & );
    139 
    140 forall( otype RationalImpl | arithmetic( RationalImpl ) )
    141 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
    142 ostype & ?|?( ostype &, Rational(RationalImpl ) );
    143 
    144104// Local Variables: //
    145105// mode: c //
Note: See TracChangeset for help on using the changeset viewer.