Mercurial > hg > Papers > 2022 > soto-sigos
comparison Paper/src/gencontext.c @ 0:14a0e409d574
ADD fast commit
author | soto <soto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 24 Apr 2022 23:13:44 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:14a0e409d574 |
---|---|
1 #include <stdlib.h> | |
2 #include "../context.h" | |
3 void initContext(struct Context* context) { | |
4 context->heapLimit = sizeof(union Data)* ALLOCATE_SIZE; | |
5 context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); | |
6 context->data = NEWN(ALLOCATE_SIZE, union Data*); | |
7 context->heapStart = NEWN(context->heapLimit, char); | |
8 context->heap = context->heapStart; | |
9 context->code[C_cs1] = cs1_stub; | |
10 context->code[C_cs2] = cs2_stub; | |
11 context->code[C_exit_code] = exit_code_stub; | |
12 context->code[C_start_code] = start_code_stub; | |
13 #include "dataGearInit.c" | |
14 } | |
15 __code meta(struct Context* context, enum Code next) { | |
16 // printf("meta %d\n",next); | |
17 goto (context->code[next])(context); | |
18 } | |
19 __code start_code(struct Context* context) { | |
20 goto meta(context, context->next); | |
21 } | |
22 __code start_code_stub(struct Context* | |
23 context) { | |
24 goto start_code(context); | |
25 } | |
26 __code exit_code(struct Context* context) { | |
27 free(context->code); | |
28 free(context->data); | |
29 free(context->heapStart); | |
30 goto exit(0); | |
31 } | |
32 __code exit_code_stub(struct Context* context ){ | |
33 goto exit_code(context); | |
34 } |