Mercurial > hg > Members > Moririn
view src/allocate/allocate.c @ 16:481760d44d87
modify
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 Apr 2015 03:47:15 +0900 |
parents | 907c69e21e56 |
children | 1eb599acffe4 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "allocateContext.h" #include "allocate.h" #include "origin_cs.h" #ifdef CLANG #define _CbC_retrun __return #define _CbC_environment __environment #endif #define NUM 100 extern __code initAllocateContext(struct Context* context); /* __code code1(Allocate allocate) { allocate.size = sizeof(long); allocate.next = Code2; goto Allocate(allocate); } */ __code code1(struct Context* context) { context->data[0]->allocate.size = sizeof(long); context->data[0]->allocate.next = Code2; goto meta(context, Allocate); } __code meta(struct Context* context, enum Code next) { goto (context->code[next])(context); } /* __code code2(Allocate allocate, Count count) { count.count = 0; goto code3(count); } */ __code code2(struct Context* context) { context->data[1]->count = 0; goto meta(context, Code3); } __code code3(struct Context* context) { long loop = context->data[1]->count; if (loop == NUM) { goto meta(context, Exit); } printf("%ld\n", loop); context->data[1]->count++; goto meta(context, Code3); } int main() { struct Context* context = (struct Context*)malloc(sizeof(struct Context)); context->code = malloc(sizeof(__code*)*1024); context->data = malloc(sizeof(union Data**)*1024); for (int i=0;i<1024;i++) context->data[i] = malloc(sizeof(union Data*)); initAllocateContext(context); goto start_code(context, Code1); }