Mercurial > hg > CbC > old > akasha
changeset 4:d41e349d6e22
Fix filename
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 13 Mar 2016 18:23:18 +0900 |
parents | c80e44ac8f5e |
children | 82a81eaff050 |
files | README src/insert_verification/CMakeLists.txt src/insert_verification/akashaCS.c src/insert_verification/akashaLLRBContext.c src/insert_verification/akasha_cs.c src/insert_verification/akasha_llrb_context.c src/insert_verification/include/akashaCS.h src/insert_verification/include/akashaLLRBContext.h src/insert_verification/include/akasha_cs.h src/insert_verification/include/akasha_llrb_context.h src/insert_verification/include/llrbContext.h src/insert_verification/include/origin_cs.h |
diffstat | 12 files changed, 210 insertions(+), 208 deletions(-) [+] |
line wrap: on
line diff
--- a/README Sun Mar 13 18:19:40 2016 +0900 +++ b/README Sun Mar 13 18:23:18 2016 +0900 @@ -15,6 +15,7 @@ # Coding Rules -naming rule: camelCase. +variable naming rule: camelCase +file naming rule: camelCase tab: soft tab (4 spaces)
--- a/src/insert_verification/CMakeLists.txt Sun Mar 13 18:19:40 2016 +0900 +++ b/src/insert_verification/CMakeLists.txt Sun Mar 13 18:23:18 2016 +0900 @@ -8,8 +8,9 @@ include_directories(${llrb_path}) add_executable(insert_verification main.c - akasha_cs.c - akasha_llrb_context.c + akashaCS.c + akashaLLRBContext.c + ${llrb_path}/allocate.c # TODO: create file in akasha ${llrb_path}/compare.c # TODO: create file in akasha ${llrb_path}/stack.c # TODO: create file in akasha
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/insert_verification/akashaCS.c Sun Mar 13 18:23:18 2016 +0900 @@ -0,0 +1,17 @@ +#include <stdlib.h> +#include "llrbContext.h" + +__code meta(struct Context* context, enum Code next) { + goto (context->code[next])(context); +} + +__code start_code(struct Context* context, enum Code next) { + goto meta(context, next); +} + +__code exit_code(struct Context* context) { + free(context->code); + free(context->data); + free(context->heapStart); + goto exit(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/insert_verification/akashaLLRBContext.c Sun Mar 13 18:23:18 2016 +0900 @@ -0,0 +1,83 @@ +#include <stdlib.h> + +#include "akashaLLRBContext.h" + +extern __code meta(struct Context*); +extern __code put_stub(struct Context*); +extern __code replaceNode_stub(struct Context*); +extern __code insertNode_stub(struct Context*); +extern __code rotateLeft_stub(struct Context*); +extern __code rotateRight_stub(struct Context*); +extern __code colorFlip_stub(struct Context*); +extern __code fixUp_stub(struct Context*); +extern __code changeReference_stub(struct Context*); +extern __code insert1_stub(struct Context*); +extern __code insert2_stub(struct Context*); +extern __code insert3_stub(struct Context*); +extern __code insert4_stub(struct Context*); +extern __code insert4_1_stub(struct Context*); +extern __code insert4_2_stub(struct Context*); +extern __code insert5_stub(struct Context*); +extern __code stackClear_stub(struct Context*); +extern __code get_stub(struct Context*); +extern __code search_stub(struct Context*); +extern __code delete_stub(struct Context*); +extern __code delete1_stub(struct Context*); +extern __code delete2_stub(struct Context*); +extern __code delete3_stub(struct Context*); +extern __code replaceNodeForDelete1_stub(struct Context*); +extern __code replaceNodeForDelete2_stub(struct Context*); +extern __code findMax1_stub(struct Context*); +extern __code findMax2_stub(struct Context*); +extern __code deleteCase1_stub(struct Context*); +extern __code deleteCase2_stub(struct Context*); +extern __code deleteCase3_stub(struct Context*); +extern __code deleteCase4_stub(struct Context*); +extern __code deleteCase5_stub(struct Context*); +extern __code deleteCase6_stub(struct Context*); +extern __code exit_code(struct Context*); + +__code initLLRBContext(struct Context* context, int num) { + context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; + context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); + context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); + context->heapStart = malloc(context->heapLimit); + + context->codeNum = Exit; + + context->code[Put] = put_stub; + context->code[Replace] = replaceNode_stub; + context->code[Insert] = insertNode_stub; + context->code[RotateL] = rotateLeft_stub; + context->code[RotateR] = rotateRight_stub; + context->code[InsertCase1] = insert1_stub; + context->code[InsertCase2] = insert2_stub; + context->code[InsertCase3] = insert3_stub; + context->code[InsertCase4] = insert4_stub; + context->code[InsertCase4_1] = insert4_1_stub; + context->code[InsertCase4_2] = insert4_2_stub; + context->code[InsertCase5] = insert5_stub; + context->code[StackClear] = stackClear_stub; + context->code[Exit] = exit_code; + + context->heap = context->heapStart; + + context->data[Allocate] = context->heap; + context->heap += sizeof(struct Allocate); + + context->data[Tree] = context->heap; + context->heap += sizeof(struct Tree); + + context->data[Node] = context->heap; + context->heap += sizeof(struct Node); + + context->dataNum = Node; + + struct Tree* tree = &context->data[Tree]->tree; + tree->root = 0; + tree->current = 0; + tree->deleted = 0; + + context->node_stack = stack_init(sizeof(struct Node*), 100); + context->code_stack = stack_init(sizeof(enum Code), 100); +}
--- a/src/insert_verification/akasha_cs.c Sun Mar 13 18:19:40 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#include <stdlib.h> -#include "llrbContext.h" - -__code meta(struct Context* context, enum Code next) { - goto (context->code[next])(context); -} - -__code start_code(struct Context* context, enum Code next) { - goto meta(context, next); -} - -__code exit_code(struct Context* context) { - free(context->code); - free(context->data); - free(context->heapStart); - goto exit(0); -}
--- a/src/insert_verification/akasha_llrb_context.c Sun Mar 13 18:19:40 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -#include <stdlib.h> - -#include "akasha_llrb_context.h" - -extern __code meta(struct Context*); -extern __code put_stub(struct Context*); -extern __code replaceNode_stub(struct Context*); -extern __code insertNode_stub(struct Context*); -extern __code rotateLeft_stub(struct Context*); -extern __code rotateRight_stub(struct Context*); -extern __code colorFlip_stub(struct Context*); -extern __code fixUp_stub(struct Context*); -extern __code changeReference_stub(struct Context*); -extern __code insert1_stub(struct Context*); -extern __code insert2_stub(struct Context*); -extern __code insert3_stub(struct Context*); -extern __code insert4_stub(struct Context*); -extern __code insert4_1_stub(struct Context*); -extern __code insert4_2_stub(struct Context*); -extern __code insert5_stub(struct Context*); -extern __code stackClear_stub(struct Context*); -extern __code get_stub(struct Context*); -extern __code search_stub(struct Context*); -extern __code delete_stub(struct Context*); -extern __code delete1_stub(struct Context*); -extern __code delete2_stub(struct Context*); -extern __code delete3_stub(struct Context*); -extern __code replaceNodeForDelete1_stub(struct Context*); -extern __code replaceNodeForDelete2_stub(struct Context*); -extern __code findMax1_stub(struct Context*); -extern __code findMax2_stub(struct Context*); -extern __code deleteCase1_stub(struct Context*); -extern __code deleteCase2_stub(struct Context*); -extern __code deleteCase3_stub(struct Context*); -extern __code deleteCase4_stub(struct Context*); -extern __code deleteCase5_stub(struct Context*); -extern __code deleteCase6_stub(struct Context*); -extern __code exit_code(struct Context*); - -__code initLLRBContext(struct Context* context, int num) { - context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; - context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); - context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); - context->heapStart = malloc(context->heapLimit); - - context->codeNum = Exit; - - context->code[Put] = put_stub; - context->code[Replace] = replaceNode_stub; - context->code[Insert] = insertNode_stub; - context->code[RotateL] = rotateLeft_stub; - context->code[RotateR] = rotateRight_stub; - context->code[InsertCase1] = insert1_stub; - context->code[InsertCase2] = insert2_stub; - context->code[InsertCase3] = insert3_stub; - context->code[InsertCase4] = insert4_stub; - context->code[InsertCase4_1] = insert4_1_stub; - context->code[InsertCase4_2] = insert4_2_stub; - context->code[InsertCase5] = insert5_stub; - context->code[StackClear] = stackClear_stub; - context->code[Exit] = exit_code; - - context->heap = context->heapStart; - - context->data[Allocate] = context->heap; - context->heap += sizeof(struct Allocate); - - context->data[Tree] = context->heap; - context->heap += sizeof(struct Tree); - - context->data[Node] = context->heap; - context->heap += sizeof(struct Node); - - context->dataNum = Node; - - struct Tree* tree = &context->data[Tree]->tree; - tree->root = 0; - tree->current = 0; - tree->deleted = 0; - - context->node_stack = stack_init(sizeof(struct Node*), 100); - context->code_stack = stack_init(sizeof(enum Code), 100); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/insert_verification/include/akashaCS.h Sun Mar 13 18:23:18 2016 +0900 @@ -0,0 +1,3 @@ +extern __code start_code(struct Context* context, enum Code next); +extern __code exit_code(struct Context* context); +extern __code meta(struct Context* context, enum Code next);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/insert_verification/include/akashaLLRBContext.h Sun Mar 13 18:23:18 2016 +0900 @@ -0,0 +1,100 @@ +/* Context definition for llrb example */ +#include "stack.h" + +#define ALLOCATE_SIZE 1000 + +enum Code { + Allocator, + Put, + Replace, + Insert, + Compare, + RotateL, + RotateR, + SetTree, + InsertCase1, + InsertCase2, + InsertCase3, + InsertCase4, + InsertCase4_1, + InsertCase4_2, + InsertCase5, + StackClear, + Get, + Search, + Delete, + Delete1, + Delete2, + Delete3, + Replace_d1, + Replace_d2, + FindMax1, + FindMax2, + DeleteCase1, + DeleteCase2, + DeleteCase3, + DeleteCase4, + DeleteCase5, + DeleteCase6, + Exit, +}; + +enum Relational { + EQ, + GT, + LT, +}; + +enum UniqueData { + Allocate, + Tree, + Node, +}; + +struct Context { + enum Code next; + int codeNum; + __code (**code) (struct Context*); + void* heapStart; + void* heap; + long heapLimit; + int dataNum; + stack_ptr code_stack; + stack_ptr node_stack; + union Data **data; +}; + +union Data { + struct Comparable { // inteface + enum Code compare; + union Data* data; + } compare; + struct Count { + enum Code next; + long i; + } count; + struct Tree { + enum Code next; + struct Node* root; + struct Node* current; + struct Node* deleted; + int result; + } tree; + struct Node { + // need to tree + enum Code next; + int key; // comparable data segment + int value; + struct Node* left; + struct Node* right; + // need to balancing + enum Color { + Red, + Black, + } color; + } node; + struct Allocate { + enum Code next; + long size; + } allocate; +};
--- a/src/insert_verification/include/akasha_cs.h Sun Mar 13 18:19:40 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -extern __code start_code(struct Context* context, enum Code next); -extern __code exit_code(struct Context* context); -extern __code meta(struct Context* context, enum Code next);
--- a/src/insert_verification/include/akasha_llrb_context.h Sun Mar 13 18:19:40 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* Context definition for llrb example */ -#include "stack.h" - -#define ALLOCATE_SIZE 1000 - -enum Code { - Allocator, - Put, - Replace, - Insert, - Compare, - RotateL, - RotateR, - SetTree, - InsertCase1, - InsertCase2, - InsertCase3, - InsertCase4, - InsertCase4_1, - InsertCase4_2, - InsertCase5, - StackClear, - Get, - Search, - Delete, - Delete1, - Delete2, - Delete3, - Replace_d1, - Replace_d2, - FindMax1, - FindMax2, - DeleteCase1, - DeleteCase2, - DeleteCase3, - DeleteCase4, - DeleteCase5, - DeleteCase6, - Exit, -}; - -enum Relational { - EQ, - GT, - LT, -}; - -enum UniqueData { - Allocate, - Tree, - Node, -}; - -struct Context { - enum Code next; - int codeNum; - __code (**code) (struct Context*); - void* heapStart; - void* heap; - long heapLimit; - int dataNum; - stack_ptr code_stack; - stack_ptr node_stack; - union Data **data; -}; - -union Data { - struct Comparable { // inteface - enum Code compare; - union Data* data; - } compare; - struct Count { - enum Code next; - long i; - } count; - struct Tree { - enum Code next; - struct Node* root; - struct Node* current; - struct Node* deleted; - int result; - } tree; - struct Node { - // need to tree - enum Code next; - int key; // comparable data segment - int value; - struct Node* left; - struct Node* right; - // need to balancing - enum Color { - Red, - Black, - } color; - } node; - struct Allocate { - enum Code next; - long size; - } allocate; -};