Ignore:
Timestamp:
Mar 10, 2020, 10:49:25 AM (20 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
dfda49f
Parents:
9867cdb (diff), 6565321 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/coroutine/suspend_then.cfa

    r9867cdb rff489bf  
    1515
    1616#include <fstream.hfa>
    17 #include <coroutine.hfa>
    1817
    19 void then() {
    20         sout | "Then!";
    21 }
    22 
    23 coroutine Fibonacci { int fn; };                                                // used for communication
     18generator Fibonacci {
     19        int fn;                                                                         // used for communication
     20        int fn1, fn2;                                                           // retained between resumes
     21};
    2422
    2523void main( Fibonacci & fib ) with( fib ) {                              // called on first resume
    26         int fn1, fn2;                                                           // retained between resumes
    2724        fn = 0;  fn1 = fn;                                                      // 1st case
    28         suspend_then(then);                                                     // restart last resume
     25        suspend { sout | "Then!"; }                                             // restart last resume
    2926        fn = 1;  fn2 = fn1;  fn1 = fn;                                  // 2nd case
    30         suspend_then(then);                                                     // restart last resume
     27        suspend { sout | "Then!"; }                                             // restart last resume
    3128        for () {
    3229                fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
    33                 suspend_then(then);                                             // restart last resume
     30                suspend { sout | "Then!"; }                                     // restart last resume
    3431        } // for
    3532}
Note: See TracChangeset for help on using the changeset viewer.