Mercurial > hg > Gears > GearsAgda
comparison src/list/list.c @ 35:2bdd8e2118c7
Add tail pointer to List data segment
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 05 May 2015 21:16:04 +0900 |
parents | c3314208d7b9 |
children | 2ff693c5563c |
comparison
equal
deleted
inserted
replaced
34:c3314208d7b9 | 35:2bdd8e2118c7 |
---|---|
18 goto (context->code[next])(context); | 18 goto (context->code[next])(context); |
19 } | 19 } |
20 | 20 |
21 __code meta_code2(struct Context* context, enum Code next) { | 21 __code meta_code2(struct Context* context, enum Code next) { |
22 context->data[List]->list.head = context->data[context->dataNum]; | 22 context->data[List]->list.head = context->data[context->dataNum]; |
23 context->data[List]->list.current = context->data[List]->list.head; | 23 context->data[List]->list.tail = context->data[List]->list.head; |
24 context->data[context->dataNum]->element.next = 0; | 24 context->data[context->dataNum]->element.next = 0; |
25 goto (context->code[next])(context); | 25 goto (context->code[next])(context); |
26 } | 26 } |
27 | 27 |
28 __code code2(struct Context* context) { | 28 __code code2(struct Context* context) { |
37 context->data[context->dataNum] -> element.value = 10; | 37 context->data[context->dataNum] -> element.value = 10; |
38 goto meta(context, Append); | 38 goto meta(context, Append); |
39 } | 39 } |
40 | 40 |
41 __code meta_append(struct Context* context, enum Code next) { | 41 __code meta_append(struct Context* context, enum Code next) { |
42 if (context->data[List]->list.current->element.next) { | 42 context->data[List]->list.tail->element.next = context->data[context->dataNum]; |
43 context->data[List]->list.current = context->data[List]->list.current->element.next; | 43 context->data[List]->list.tail = context->data[List]->list.tail->element.next; |
44 goto meta_append(context, next); | 44 context->data[List]->list.tail->element.next = 0; |
45 } | |
46 context->data[List]->list.current->element.next = context->data[context->dataNum]; | |
47 goto (context->code[next])(context); | 45 goto (context->code[next])(context); |
48 } | 46 } |
49 | 47 |
50 __code append(struct Context* context) { | 48 __code append(struct Context* context) { |
51 context->data[List]->list.current = context->data[List]->list.head; | |
52 goto meta_append(context, context->data[Allocate]->allocate.after_append); | 49 goto meta_append(context, context->data[Allocate]->allocate.after_append); |
53 } | 50 } |
54 | 51 |
55 | 52 |
56 __code meta_traverse(struct Context* context, enum Code next) { | 53 __code meta_traverse(struct Context* context, enum Code next) { |