Mercurial > hg > Gears > GearsAgda
view src/list/list.c @ 58:4283b87ddbf4
Add stub to synchronizedQueues
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Jun 2015 15:59:48 +0900 |
parents | 2ff693c5563c |
children |
line wrap: on
line source
#include <stdlib.h> #include <stdio.h> #include "listContext.h" #include "allocate.h" #include "origin_cs.h" extern __code initListContext(struct Context* context); __code code1(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(struct Element); allocate->next = Code2; goto meta(context, Allocator); } __code code1_stub(struct Context* context) { goto code1(context, &context->data[Allocate]->allocate); } __code meta(struct Context* context, enum Code next) { goto (context->code[next])(context); } __code code2(struct Context* context, struct Allocate* allocate, struct Element* element) { allocate->after_append = Code3; element ->value = 10; goto meta(context, Append); } __code code2_stub(struct Context* context) { goto code2(context, &context->data[Allocate]->allocate, &context->data[context->dataNum]->element); } __code append(struct Context* context, struct Allocate* allocate, struct List* list, struct Element* element) { if(list->head) { list->tail->next = element; } else { list->head = element; } list->tail = element; list->tail->next = 0; goto meta(context, allocate->after_append); } __code append_stub(struct Context* context) { goto append(context,&context->data[Allocate]->allocate, &context->data[List]->list, &context->data[context->dataNum]->element); } __code code3(struct Context* context, struct Allocate *allocate) { allocate->size = sizeof(struct Element); allocate->next = Code4; goto meta(context, Allocator); } __code code3_stub(struct Context* context) { goto code3(context, &context->data[Allocate]->allocate); } __code code4(struct Context* context, struct Allocate* allocate, struct Element* element) { allocate->after_append = Code5; element ->value = 100; goto meta(context, Append); } __code code4_stub(struct Context* context) { goto code4(context, &context->data[Allocate]->allocate, &context->data[context->dataNum]->element); } __code meta_traverse(struct Context* context, struct List* list, enum Code next) { printf("current value in list is %d\n", list->current->value); if (list->current->next) { list->current = list->current->next; goto meta_traverse(context, list, next); } goto (context->code[next])(context); } __code traverse(struct Context* context, struct Allocate* allocate, struct List* list) { list->current = list->head; goto meta_traverse(context, list, allocate->after_traverse); } __code traverse_stub(struct Context* context) { goto traverse(context, &context->data[Allocate]->allocate, &context->data[List]->list); } __code code5(struct Context* context, struct Allocate* allocate) { allocate->after_traverse = Code6; goto meta(context, Traverse); } __code code5_stub(struct Context* context) { goto code5(context, &context->data[Allocate]->allocate); } __code code6(struct Context* context, struct Allocate* allocate) { allocate->after_delete = Code7; goto meta(context, Delete); } __code code6_stub(struct Context* context) { goto code6(context, &context->data[Allocate]->allocate); } __code delete(struct Context* context, struct Allocate* allocate, struct List* list) { list->head = (list->head->next) ? list->head->next : 0; goto meta(context, allocate->after_delete); } __code delete_stub(struct Context* context) { goto delete(context, &context->data[Allocate]->allocate, &context->data[List]->list); } __code code7(struct Context* context, struct Allocate* allocate) { printf("after delete\n"); allocate->after_traverse = Exit; goto meta(context, Traverse); } __code code7_stub(struct Context* context) { goto code7(context, &context->data[Allocate]->allocate); } int main() { struct Context* context = (struct Context*)malloc(sizeof(struct Context)); initListContext(context); goto start_code(context, Code1); }