annotate paper/source/allocate.h @ 10:92f7c78d8d6c

edit
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Wed, 06 May 2015 19:55:44 +0900
parents bb5fab31cf41
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
1 // Code Gear
8
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 __code code1(struct Context* context) {
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 context->data[Allocate]->allocate.size = sizeof(struct Node);
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 context->data[Allocate]->allocate.next = Code2;
10
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
5 goto meta(context, Allocate);
8
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 }
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
10
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
8 // Meta Code Gear
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
9 __code meta(struct Context* context, enum Code next) {
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
10 // meta computation
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
11 goto (context->code[next])(context);
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
12 }
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
13
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
14 // Meta Code Gear
8
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 __code allocate(struct Context* context) {
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 context->data[++context->dataNum] = context->heap;
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 context->heap += context->data[Allocate]->allocate.size;
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 goto (context->code[context->data[Allocate]->allocate.next])(context);
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 }
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
10
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
21 // Code Gear
8
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 __code code2(struct Context* context) {
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 // processing content
bb5fab31cf41 add source file
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 }