Changeset e1780a2


Ignore:
Timestamp:
Aug 9, 2017, 5:56:44 PM (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:
0a5b683, 3b4571b, cd7ef0b
Parents:
0ec9229
Message:

augment "writable" trait with "ostream" to support more monomorphic IO operations, and add new "div" test using this feature

Location:
src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream

    r0ec9229 re1780a2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:35:59 2017
    13 // Update Count     : 118
     12// Last Modified On : Wed Aug  9 16:42:47 2017
     13// Update Count     : 131
    1414//
    1515
     
    4646}; // ostream
    4747
    48 trait writeable( otype T ) {
    49         forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
     48// trait writeable( otype T ) {
     49//      forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
     50// }; // writeable
     51
     52trait writeable( otype T, dtype ostype | ostream( ostype ) ) {
     53        ostype * ?|?( ostype *, T );
    5054}; // writeable
    5155
     
    7781
    7882// tuples
    79 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) ostype * ?|?( ostype * os, T arg, Params rest );
     83forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )
     84ostype * ?|?( ostype * os, T arg, Params rest );
    8085
    8186// manipulators
     
    9095
    9196// writes the range [begin, end) to the given stream
    92 forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )
    93 void write( iterator_type begin, iterator_type end, os_type *os );
     97forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     98void write( iterator_type begin, iterator_type end, ostype * os );
    9499
    95 forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )
    96 void write_reverse( iterator_type begin, iterator_type end, os_type *os );
     100forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     101void write_reverse( iterator_type begin, iterator_type end, ostype * os );
    97102
    98103//---------------------------------------
  • src/libcfa/iostream.c

    r0ec9229 re1780a2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 16 21:12:03 2017
    13 // Update Count     : 398
     12// Last Modified On : Wed Aug  9 16:46:51 2017
     13// Update Count     : 401
    1414//
    1515
     
    193193
    194194// tuples
    195 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } )
     195forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )
    196196ostype * ?|?( ostype * os, T arg, Params rest ) {
    197197        os | arg;                                                                                       // print first argument
     
    256256//---------------------------------------
    257257
    258 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) )
    259 void write( iteratortype begin, iteratortype end, ostype * os ) {
    260         void print( elttype i ) { os | i; }
     258forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     259void write( iterator_type begin, iterator_type end, ostype * os ) {
     260        void print( elt_type i ) { os | i; }
    261261        for_each( begin, end, print );
    262262} // ?|?
    263263
    264 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) )
    265 void write_reverse( iteratortype begin, iteratortype end, ostype * os ) {
    266         void print( elttype i ) { os | i; }
     264forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     265void write_reverse( iterator_type begin, iterator_type end, ostype * os ) {
     266        void print( elt_type i ) { os | i; }
    267267        for_each_reverse( begin, end, print );
    268268} // ?|?
  • src/tests/div.c

    r0ec9229 re1780a2  
    1111// Created On       : Tue Aug  8 16:28:43 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Aug  8 18:02:44 2017
    14 // Update Count     : 14
     13// Last Modified On : Wed Aug  9 17:09:40 2017
     14// Update Count     : 16
    1515//
    1616
     
    2828        sout | "div" | div( s1, s2 ) | endl;
    2929        T t1 = { 13 }, t2 = { 5 };
    30         [t1, t2] = div( t1, t2 );                                                       // polymorphic div
    31         sout | "div" | t1 | t2 | endl;
    32 //      sout | "div" | div( t1, t2 ) | endl;
     30        sout | "div" | div( t1, t2 ) | endl;                            // polymorphic div
    3331} // main
    3432
Note: See TracChangeset for help on using the changeset viewer.