Changeset 55ba7339 for src/Tests/Forall.c
- Timestamp:
- Jun 14, 2016, 12:33:57 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e04ef3a
- Parents:
- 4c82a3c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tests/Forall.c
r4c82a3c r55ba7339 7 7 8 8 void g1() { 9 forall( type T ) T f( T );9 forall( otype T ) T f( T ); 10 10 void f( int ); 11 11 void h( void (*p)(void) ); … … 24 24 25 25 void g2() { 26 forall( type T ) void f( T, T );27 forall( type T,type U ) void f( T, U );26 forall( otype T ) void f( T, T ); 27 forall( otype T, otype U ) void f( T, U ); 28 28 29 29 int x; … … 37 37 } 38 38 39 typedef forall ( type T ) int (*f)( int );39 typedef forall ( otype T ) int (*f)( int ); 40 40 41 forall( type T )41 forall( otype T ) 42 42 void swap( T left, T right ) { 43 43 T temp = left; … … 46 46 } 47 47 48 context sumable( type T ) {48 context sumable( otype T ) { 49 49 const T 0; 50 50 T ?+?(T, T); … … 53 53 }; 54 54 55 type T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); },56 T2( type P1,type P2 ),55 otype T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); }, 56 T2(otype P1, otype P2 ), 57 57 T3 | sumable(T3); 58 58 59 type T2(type P1,type P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; };59 otype T2(otype P1, otype P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; }; 60 60 61 61 T2(int, int) w1; 62 62 typedef T2(int, int) w2; 63 63 w2 g2; 64 type w3 = T2(int, int);64 otype w3 = T2(int, int); 65 65 w3 g3; 66 66 67 forall( type T | sumable( T ) )67 forall( otype T | sumable( T ) ) 68 68 T sum( int n, T a[] ) { 69 69 T total = 0; … … 74 74 } 75 75 76 forall( type T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } )76 forall( otype T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } ) 77 77 T twice( T t ) { 78 78 return t + t; 79 79 } 80 80 81 forall( type T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } )81 forall( otype T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } ) 82 82 T min( T t1, T t2 ) { 83 83 return t1 < t2 ? t1 : t2;
Note: See TracChangeset
for help on using the changeset viewer.