view src/examples/twice/printArray.cbc @ 590:9146d6017f18 default tip

hg mv parallel_execution/* ..
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 16 Jan 2020 15:12:06 +0900
parents src/parallel_execution/examples/twice/printArray.cbc@39b5adbcd83f
children
line wrap: on
line source

#include "../../../context.h"
#interface "Timer.h"
#include <stdio.h>

__code printArray(struct Array* array, struct Timer* inputTimer, __code next(...)){
    goto inputTimer->end(printArray1);
}

__code printArray1(struct Array* array, __code next(...), struct LoopCounter* loopCounter){
    int i = loopCounter->i;
    //printf("%d\n", array->array[i]);
    if (i < GET_LEN(array->array)) {
        if (array->array[i].value == i*2) {
            loopCounter->i++;
            goto printArray1();
        } else {
            printf("wrong result\n");
        }
    }
   loopCounter->i = 0;
    goto next(...);
}