34
|
1 #include <stdlib.h>
|
|
2
|
|
3 #include "listContext.h"
|
|
4
|
55
|
5 extern __code code1_stub(struct Context*);
|
|
6 extern __code code2_stub(struct Context*);
|
|
7 extern __code code3_stub(struct Context*);
|
|
8 extern __code code4_stub(struct Context*);
|
|
9 extern __code code5_stub(struct Context*);
|
|
10 extern __code code6_stub(struct Context*);
|
|
11 extern __code code7_stub(struct Context*);
|
34
|
12 extern __code meta(struct Context*);
|
|
13 extern __code allocate(struct Context*);
|
55
|
14 extern __code append_stub(struct Context*);
|
|
15 extern __code traverse_stub(struct Context*);
|
|
16 extern __code delete_stub(struct Context*);
|
34
|
17 extern __code exit_code(struct Context*);
|
|
18
|
|
19 __code initListContext(struct Context* context) {
|
|
20 context->dataSize = sizeof(union Data)*ALLOCATE_SIZE;
|
|
21 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
|
|
22 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
|
|
23 context->heap_start = malloc(context->dataSize);
|
|
24
|
|
25 context->codeNum = Exit;
|
|
26 context->code[Allocator] = allocate;
|
55
|
27 context->code[Code1] = code1_stub;
|
|
28 context->code[Code2] = code2_stub;
|
|
29 context->code[Code3] = code3_stub;
|
|
30 context->code[Code4] = code4_stub;
|
|
31 context->code[Code5] = code5_stub;
|
|
32 context->code[Code6] = code6_stub;
|
|
33 context->code[Code7] = code7_stub;
|
|
34 context->code[Append] = append_stub;
|
|
35 context->code[Traverse] = traverse_stub;
|
|
36 context->code[Delete] = delete_stub;
|
34
|
37 context->code[Exit] = exit_code;
|
|
38
|
|
39 context->heap = context->heap_start;
|
|
40
|
|
41 context->data[Allocate] = context->heap;
|
|
42 context->heap += sizeof(struct Allocate);
|
|
43
|
|
44 context->data[List] = context->heap;
|
|
45 context->heap += sizeof(struct List);
|
|
46
|
|
47 context->dataNum = List;
|
|
48 }
|