Changeset f802e46


Ignore:
Timestamp:
Oct 1, 2017, 9:59:17 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1033f5d, 72ae87c
Parents:
6e49f18
Message:

cleanup code

Location:
src/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine.c

    r6e49f18 rf802e46  
    1010// Created On       : Thu Jun  8 07:29:37 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  8 07:37:12 2017
    13 // Update Count     : 5
     12// Last Modified On : Sun Sep 17 21:38:15 2017
     13// Update Count     : 7
    1414//
    1515
     
    1818
    1919coroutine Fibonacci {
    20         int fn;                                         // used for communication
     20        int fn;                                                                                         // used for communication
    2121};
    2222
     
    2626
    2727void main( Fibonacci & this ) {
    28         int fn1, fn2;                                   // retained between resumes
    29         this.fn = 0;                                    // case 0
     28        int fn1, fn2;                                                                           // retained between resumes
     29        this.fn = 0;                                                                            // case 0
    3030        fn1 = this.fn;
    31         suspend();                                              // return to last resume
     31        suspend();                                                                                      // restart last resume
    3232
    33         this.fn = 1;                                    // case 1
    34         fn2 = fn1;
    35         fn1 = this.fn;
    36         suspend();                                              // return to last resume
     33        this.fn = 1;                                                                            // case 1
     34        fn2 = fn1;  fn1 = this.fn;
     35        suspend();                                                                                      // restart last resume
    3736
    38         for ( ;; ) {                                    // general case
     37        for ( ;; ) {                                                                            // general case
    3938                this.fn = fn1 + fn2;
    40                 fn2 = fn1;
    41                 fn1 = this.fn;
    42                 suspend();                                      // return to last resume
     39                fn2 = fn1;  fn1 = this.fn;
     40                suspend();                                                                              // restart last resume
    4341        } // for
    4442}
    4543
    4644int next( Fibonacci & this ) {
    47         resume( this );                                 // transfer to last suspend
     45        resume( this );                                                                         // restart last suspend
    4846        return this.fn;
    4947}
     
    5250        Fibonacci f1, f2;
    5351        for ( int i = 1; i <= 10; i += 1 ) {
    54                 sout | next( f1 ) | ' ' | next( f2 ) | endl;
     52                sout | next( f1 ) | next( f2 ) | endl;
    5553        } // for
    5654}
  • src/tests/gmp.c

    r6e49f18 rf802e46  
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  4 09:51:18 2017
    13 // Update Count     : 550
     12// Last Modified On : Thu Sep 28 18:33:51 2017
     13// Update Count     : 555
    1414//
    1515
     
    9797
    9898        sout | "Factorial Numbers" | endl;
    99         Int fact;
    100         fact = 1;                                                                                       // 1st case
     99        Int fact = 1;                                                                           // 1st case
    101100        sout | (int)0 | fact | endl;
    102101        for ( unsigned int i = 1; i <= 40; i += 1 ) {
Note: See TracChangeset for help on using the changeset viewer.