Mercurial > hg > Papers > 2016 > kkb-master
comparison paper/src/allocate.c @ 16:958634b9fa32
make paper directory
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 17 Feb 2016 16:59:46 +0900 |
parents | src/allocate.c@52eec0b77576 |
children |
comparison
equal
deleted
inserted
replaced
15:94c9c506bba9 | 16:958634b9fa32 |
---|---|
1 // Code Gear | |
2 __code start_code(struct Context* context) { | |
3 // start processing | |
4 goto meta(context, context->next); | |
5 } | |
6 | |
7 // Meta Code Gear | |
8 __code meta(struct Context* context, enum Code next) { | |
9 // meta computation | |
10 goto (context->code[next])(context); | |
11 } | |
12 | |
13 // Code Gear | |
14 __code code1(struct Context* context, struct Allocate* allocate) { | |
15 allocate->size = sizeof(struct Data1); | |
16 context->next = Code2; | |
17 | |
18 goto meta(context, Allocator); | |
19 } | |
20 | |
21 // Meta Code Gear(stub) | |
22 __code code1_stub(struct Context* context) { | |
23 goto code1(context, &context->data[Allocate]->allocate); | |
24 } | |
25 | |
26 // Meta Code Gear | |
27 __code allocator(struct Context* context, struct Allocate* allocate) { | |
28 context->data[++context->dataNum] = context->heap; | |
29 context->heap += allocate->size; | |
30 | |
31 goto meta(context, context->next); | |
32 } | |
33 | |
34 // Meta Code Gear(stub) | |
35 __code allocator_stub(struct Context* context) { | |
36 goto allocator(context, &context->data[Allocate]->allcate); | |
37 } | |
38 | |
39 // Code Gear | |
40 __code code2(struct Context* context, struct Data1* data1) { | |
41 // processing | |
42 } | |
43 | |
44 // Meta Code Gear(stub) | |
45 __code code2_stub(struct Context* context) { | |
46 goto code2(context, &context->data[context->dataNum]->data1); | |
47 } |