view src/parallel_execution/examples/pop_and_push/StackTestImpl3.cbc @ 1032:793b21a8ea12

fix include
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 24 Oct 2023 12:25:40 +0900
parents 3c0f1139e464
children
line wrap: on
line source

#interface "StackTest.h"
#interface "StackTest2.h"
#interface "Stack.h"
#include <stdio.h>

#interface "String.h"

#impl "StackTest.h" as "StackTestImpl3.h"


__code insertTest1(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
    String* str = &ALLOCATE(context, String)->String;
    str->size = 99;
    Meta* secondeMeta = (Meta*)(context->heapStart + (sizeof(Meta)*2));
    printf("seconde: %d\n", secondeMeta->type);
    Meta* prevMeta = GET_PREV_META(str);
    printf("prev: %d\n", prevMeta->type);
    printf("str: %d\n", GET_TYPE(str));
    goto stack->push((union Data*)str, insertTest2);
}

__code insertTest2(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
    String* str = &ALLOCATE(context, String)->String;
    str->size = 100;
    goto stack->push((union Data*)str, pop2Test);
}


__code pop2Test(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
    goto stack->pop2(pop2Test1);
}

__code pop2Test3(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
    String* str = &ALLOCATE(context, String)->String;
    str->size = 200;
    String* str1 = &ALLOCATE(context, String)->String;
    str1->size = 300;
    union Data* data = (union Data*)str;
    union Data* data1 = (union Data*)str1;

    goto pop2Test1(stackTest, data, data1);
}


__code pop2Test1(struct StackTestImpl3* stackTest, union Data* data, union Data* data1, struct Stack* stack, __code next(...)) {
    String* str = (String*)data;
    String* str2 = (String*)data1;

    printf("%d\n", str->size);
    printf("%d\n", str2->size);
    goto next(...);
}


__code insertTest3(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
    StackTest2* stackTest2 = createStackTest2Impl(context);
    String* str = &ALLOCATE(context, String)->String;
    str->size = 100;
    goto stackTest2->insertTest1(stack, (union Data*)str, pop2Test);
}

__code insertTest4(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
    StackTest2* stackTest2 = createStackTest2Impl(context);
    String* str = &ALLOCATE(context, String)->String;
    str->size = 100;
    goto stackTest2->insertTest1(stack, (union Data*)str, pop2Test);
}