ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since edf3ff1 was
427854b,
checked in by Thierry Delisle <tdelisle@…>, 5 years ago
|
First draft implementation of generators, still missing error checking, testing and clean-up
|
-
Property mode set to
100644
|
File size:
722 bytes
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2017 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 | // fibonacci.cfa |
---|
8 | // |
---|
9 | // Author : Thierry Delisle |
---|
10 | // Created On : Mon Mar 1 16:54:23 2020 |
---|
11 | // Last Modified By : |
---|
12 | // Last Modified On : |
---|
13 | // Update Count : |
---|
14 | // |
---|
15 | |
---|
16 | generator Fib { |
---|
17 | int fn1, fn; |
---|
18 | }; |
---|
19 | |
---|
20 | void main(Fib & b) with (b) { |
---|
21 | [fn1, fn] = [1, 0]; |
---|
22 | for () { |
---|
23 | suspend; |
---|
24 | [fn1, fn] = [fn, fn + fn1]; |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | int main() { |
---|
29 | Fib f1, f2; |
---|
30 | for ( 10 ) { |
---|
31 | resume( f1 ); |
---|
32 | resume( f2 ); |
---|
33 | printf("%d %d\n", f1.fn, f2.fn); |
---|
34 | } |
---|
35 | |
---|
36 | } |
---|
37 | |
---|
38 | // Local Variables: // |
---|
39 | // tab-width: 4 // |
---|
40 | // compile-command: "cfa fibonacci.cfa" // |
---|
41 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.