source: tests/loopctrl.cfa@ 5307c33

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr no_list persistent-indexer pthread-emulation qualifiedEnum
Last change on this file since 5307c33 was 61dafb8, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

finish test and documentation for loop-control

  • Property mode set to 100644
File size: 3.2 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// loopctrl.cfa --
8//
9// Author : Peter A. Buhr
10// Created On : Wed Aug 8 18:32:59 2018
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Nov 7 16:54:11 2018
13// Update Count : 62
14//
15
16#include <fstream.hfa>
17
18struct S { int i, j; };
19void ?{}( S & s ) { s.[i, j] = 0; }
20void ?{}( S & s, int i ) { s.[i, j] = [i, 0]; }
21void ?{}( S & s, int i, int j ) { s.[i, j] = [i, j]; }
22void ?{}( S & s, zero_t ) { s.[i, j] = 0; }
23void ?{}( S & s, one_t ) { s.[i, j] = 1; }
24int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; }
25int ?<=?( S t1, S t2 ) { return t1.i <= t2.i && t1.j <= t2.j; }
26int ?>?( S t1, S t2 ) { return t1.i > t2.i && t1.j > t2.j; }
27int ?>=?( S t1, S t2 ) { return t1.i >= t2.i && t1.j >= t2.j; }
28S ?=?( S & t1, S t2 ) { t1.i = t2.i; t1.j = t2.j; return t1; }
29S ?+=?( S & t1, S t2 ) { t1.i += t2.i; t1.j += t2.j; return t1; }
30S ?+=?( S & t, one_t ) { t.i += 1; t.j += 1; return t; }
31S ?-=?( S & t1, S t2 ) { t1.i -= t2.i; t1.j -= t2.j; return t1; }
32S ?-=?( S & t, one_t ) { t.i -= 1; t.j -= 1; return t; }
33ofstream & ?|?( ofstream & os, S v ) { return os | '(' | v.i | v.j | ')'; }
34
35int main() {
36 while () { sout | "empty"; break; } sout | endl;
37 do { sout | "empty"; break; } while (); sout | endl;
38 for () { sout | "empty"; break; } sout | endl | endl;
39
40 for ( 0 ) { sout | "A"; } sout | "zero" | endl;
41 for ( 1 ) { sout | "A"; } sout | endl;
42 for ( 10 ) { sout | "A"; } sout | endl;
43 for ( 1 ~= 10 ~ 2 ) { sout | "B"; } sout | endl;
44 for ( 10 -~= 1 ~ 2 ) { sout | "C"; } sout | endl;
45 for ( 0.5 ~ 5.5 ) { sout | "D"; } sout | endl;
46 for ( 5.5 -~ 0.5 ) { sout | "E"; } sout | endl | endl;
47
48 for ( i; 10 ) { sout | i; } sout | endl;
49 for ( i; 1 ~= 10 ~ 2 ) { sout | i; } sout | endl;
50 for ( i; 10 -~= 1 ~ 2 ) { sout | i; } sout | endl;
51 for ( i; 0.5 ~ 5.5 ) { sout | i; } sout | endl;
52 for ( i; 5.5 -~ 0.5 ) { sout | i; } sout | endl;
53 for ( ui; 2u ~= 10u ~ 2u ) { sout | ui; } sout | endl;
54 for ( ui; 10u -~= 2u ~ 2u ) { sout | ui; } sout | endl | endl | endl;
55
56 enum { N = 10 };
57 for ( N ) { sout | "N"; } sout | endl;
58 for ( i; N ) { sout | i; } sout | endl;
59 for ( i; N -~ 0 ) { sout | i; } sout | endl | endl | endl;
60
61 const int start = 3, comp = 10, inc = 2;
62 for ( i; start ~ comp ~ inc + 1 ) { sout | i; } sout | endl | endl;
63
64 sout | endl;
65 for ( S s = (S){0}; s < (S){10,10}; s += (S){1} ) { sout | s; } sout | endl;
66 for ( s; (S){10,10} ) { sout | s; } sout | endl;
67 sout | endl;
68 for ( s; (S){0} ~ (S){10,10} ) { sout | s; } sout | endl;
69 for ( s; (S){0} ~ (S){10,10} ~ (S){1} ) { sout | s; } sout | endl;
70 for ( s; (S){0} ~= (S){10,10} ) { sout | s; } sout | endl;
71 for ( s; (S){0} ~= (S){10,10} ~ (S){1} ) { sout | s; } sout | endl;
72 sout | endl;
73 for ( s; (S){10,10} -~ (S){0} ) { sout | s; } sout | endl;
74 for ( s; (S){10,10} -~ (S){0} ~ (S){1} ) { sout | s; } sout | endl;
75 for ( s; (S){10,10} -~= (S){0} ) { sout | s; } sout | endl;
76 for ( s; (S){10,10} -~= (S){0} ~ (S){1} ) { sout | s; } sout | endl;
77}
78
79// Local Variables: //
80// tab-width: 4 //
81// compile-command: "cfa loopctrl.cfa" //
82// End: //
Note: See TracBrowser for help on using the repository browser.