comparison src/llrb/llrbContext.c @ 56:c469c5ed5b4d

modify syntax
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 16 Jun 2015 13:40:08 +0900
parents 348148d8fdb1
children 025fd6e90597
comparison
equal deleted inserted replaced
54:0299b90256e5 56:c469c5ed5b4d
1 #include <stdlib.h> 1 #include <stdlib.h>
2 2
3 #include "llrbContext.h" 3 #include "llrbContext.h"
4 4
5 extern __code code1(struct Context*); 5 extern __code code1_stub(struct Context*);
6 extern __code code2(struct Context*); 6 extern __code code2_stub(struct Context*);
7 extern __code code3(struct Context*); 7 extern __code code3_stub(struct Context*);
8 extern __code code4(struct Context*); 8 extern __code code4(struct Context*);
9 extern __code code5(struct Context*); 9 extern __code code5(struct Context*);
10 extern __code code6(struct Context*); 10 extern __code code6_stub(struct Context*);
11 extern __code meta(struct Context*); 11 extern __code meta(struct Context*);
12 extern __code allocate(struct Context*); 12 extern __code allocate(struct Context*);
13 extern __code put(struct Context*); 13 extern __code put_stub(struct Context*);
14 extern __code replaceNode(struct Context*); 14 extern __code replaceNode_stub(struct Context*);
15 extern __code insertNode(struct Context*); 15 extern __code insertNode_stub(struct Context*);
16 extern __code compare(struct Context*); 16 extern __code compare_stub(struct Context*);
17 extern __code createNode(struct Context*); 17 extern __code rotateLeft_stub(struct Context*);
18 extern __code rotateLeft(struct Context*); 18 extern __code rotateRight_stub(struct Context*);
19 extern __code rotateRight(struct Context*); 19 extern __code colorFlip_stub(struct Context*);
20 extern __code colorFlip(struct Context*); 20 extern __code fixUp_stub(struct Context*);
21 extern __code fixUp(struct Context*); 21 extern __code changeReference_stub(struct Context*);
22 extern __code changeReference(struct Context*); 22 extern __code get_stub(struct Context*);
23 extern __code get(struct Context*); 23 extern __code traverse_stub(struct Context*);
24 extern __code traverse(struct Context*);
25 extern __code exit_code(struct Context*); 24 extern __code exit_code(struct Context*);
26 25
27 __code initLLRBContext(struct Context* context) { 26 __code initLLRBContext(struct Context* context) {
28 context->dataSize = sizeof(union Data)*ALLOCATE_SIZE; 27 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
28 context->next = malloc(sizeof(enum Code)*ALLOCATE_SIZE);
29 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); 29 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
30 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); 30 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
31 context->heap_start = malloc(context->dataSize); 31 context->heapStart = malloc(context->heapLimit);
32 32
33 context->codeNum = Exit; 33 context->codeNum = Exit;
34 context->code[Code1] = code1; 34 context->code[Code1] = code1_stub;
35 context->code[Code2] = code2; 35 context->code[Code2] = code2_stub;
36 context->code[Code3] = code3; 36 context->code[Code3] = code3_stub;
37 context->code[Code4] = code4; 37 context->code[Code4] = code4;
38 context->code[Code5] = code5; 38 context->code[Code5] = code5;
39 context->code[Code6] = code6;
40 context->code[Allocator] = allocate; 39 context->code[Allocator] = allocate;
41 context->code[Put] = put; 40 context->code[Put] = put_stub;
42 context->code[Replace] = replaceNode; 41 context->code[Replace] = replaceNode_stub;
43 context->code[Insert] = insertNode; 42 context->code[Insert] = insertNode_stub;
44 context->code[Compare] = compare; 43 context->code[Compare] = compare_stub;
45 context->code[Create] = createNode; 44 context->code[RotateL] = rotateLeft_stub;
46 context->code[RotateL] = rotateLeft; 45 context->code[RotateR] = rotateRight_stub;
47 context->code[RotateR] = rotateRight; 46 context->code[ColorFlip] = colorFlip_stub;
48 context->code[ColorFlip] = colorFlip; 47 context->code[FixUp] = fixUp_stub;
49 context->code[FixUp] = fixUp; 48 context->code[ChangeRef] = changeReference_stub;
50 context->code[ChangeRef] = changeReference;
51 context->code[Get] = get;
52 context->code[Traverse] = traverse;
53 context->code[Exit] = exit_code; 49 context->code[Exit] = exit_code;
54 50
55 context->heap = context->heap_start; 51 context->heap = context->heapStart;
56 52
57 context->data[Allocate] = context->heap; 53 context->data[Allocate] = context->heap;
58 context->heap += sizeof(struct Allocate); 54 context->heap += sizeof(struct Allocate);
59 55
60 context->data[Tree] = context->heap; 56 context->data[Tree] = context->heap;
61 context->heap += sizeof(struct Tree); 57 context->heap += sizeof(struct Tree);
62 58
63 context->data[Node] = context->heap; 59 context->data[Node] = context->heap;
64 context->heap += sizeof(struct Node); 60 context->heap += sizeof(struct Node);
65 61
66 context->data[Next] = context->heap; 62 context->dataNum = Node;
67 context->heap += sizeof(enum Code);
68
69 context->dataNum = Next;
70 63
71 struct Tree* tree = &context->data[Tree]->tree; 64 struct Tree* tree = &context->data[Tree]->tree;
72 tree->root = 0; 65 tree->root = 0;
73 tree->current = 0; 66 tree->current = 0;
74 tree->prev = 0; 67 tree->prev = 0;
68
75 } 69 }