Mercurial > hg > Papers > 2018 > mitsuki-prosym
view Paper/src/context2.c @ 0:dbbe5ef644fb
add
author | mir3636 |
---|---|
date | Tue, 21 Nov 2017 19:56:10 +0900 |
parents | |
children |
line wrap: on
line source
#include <stdlib.h> #include "../context.h" void initContext(struct Context* context) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); context->data = NEWN(ALLOCATE_SIZE, union Data*); context->heapStart = NEWN(context->heapLimit, char); context->heap = context->heapStart; context->code[C_clearSingleLinkedStack] = clearSingleLinkedStack_stub; context->code[C_exit_code] = exit_code_stub; context->code[C_getSingleLinkedStack] = getSingleLinkedStack_stub; context->code[C_isEmptySingleLinkedStack] = isEmptySingleLinkedStack_stub; context->code[C_popSingleLinkedStack] = popSingleLinkedStack_stub; context->code[C_pushSingleLinkedStack] = pushSingleLinkedStack_stub; context->code[C_stack_test1] = stack_test1_stub; context->code[C_stack_test2] = stack_test2_stub; context->code[C_stack_test3] = stack_test3_stub; context->code[C_stack_test4] = stack_test4_stub; context->code[C_start_code] = start_code_stub; #include "dataGearInit.c" } __code meta(struct Context* context, enum Code next) { // printf("meta %d\n",next); goto (context->code[next])(context); } __code start_code(struct Context* context) { goto meta(context, context->next); } __code start_code_stub(struct Context* context) { goto start_code(context); } __code exit_code(struct Context* context) { free(context->code); free(context->data); free(context->heapStart); goto exit(0); } __code exit_code_stub(struct Context* context) { goto exit_code(context); } // end context_c