// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // forall.cfa -- // // Author : Peter A. Buhr // Created On : Wed May 9 08:48:15 2018 // Last Modified By : Peter A. Buhr // Last Modified On : Thu Feb 2 15:28:45 2023 // Update Count : 38 // void g1() { forall( T ) T f( T ) {}; void f( int ) {}; void h( void (*p)(void) ) {}; int x; void (*y)(void); char z; float w; f( x ); f( y ); f( z ); f( w ); h( f( y ) ); } void g2() { forall( T ) void f( T, T ) {} forall( T, U ) void f( T, U ) {} int x; float y; int *z; float *w; f( x, y ); f( z, w ); f( x, z ); } // commented this out since it is not clearly meaningful // and not really representable in the ast // typedef forall ( T ) int (* f)( int ); forall( T ) void swap( T left, T right ) { T temp = left; left = right; right = temp; } forall( T ) trait sumable { void ?{}( T &, zero_t ); // 0 literal constructor T ?+?( T, T ); // assortment of additions T ?+=?( T &, T ); T ++?( T & ); T ?++( T & ); }; // sumable forall( T | sumable( T ) ) // use trait T sum( size_t size, T a[] ) { T total = 0; // initialize by 0 constructor for ( size_t i = 0; i < size; i += 1 ) total = total + a[i]; // select appropriate + return total; } // sum forall( T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } ) T twice( T t ) { return t + t; } forall( T | { int ?