Mercurial > hg > Gears > GearsAgda
view src/llrb/main.c @ 99:ca55f4be5f0f
Create verifier directory
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Feb 2016 16:02:55 +0900 |
parents | c13575c3dbe9 |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include "llrbContext.h" #include "origin_cs.h" static double st_time; static double ed_time; static clock_t c1,c2; int num; extern __code initLLRBContext(struct Context* context, int); extern void allocator(struct Context* context); static double getTime() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + (double)tv.tv_usec*1e-6; } void print_tree(struct Node* node, int n) { if (node != 0) { print_tree(node->left, n+1); for (int i=0;i<n;i++) printf(" "); printf("key=%d value=%d color=%s\t%p\n", node->key, node->value,/* n, */node->color==0? "R":"B", node); print_tree(node->right, n+1); } } /* __code code1(Allocate allocate) { allocate.size = sizeof(long); allocate.next = Code2; goto Allocate(allocate); } */ __code code1(struct Context* context, struct Allocate *allocate) { allocate->size = sizeof(struct Count); allocator(context); goto meta(context, Code2); } __code code1_stub(struct Context* context) { goto code1(context, &context->data[Allocate]->allocate); } /* __code code2(Allocate allocate, Count count) { count.count = 0; goto code3(count); } */ __code code2(struct Context* context, struct Count* count) { count->i = num; goto meta(context, Code3); } __code code2_stub(struct Context* context) { goto code2(context, &context->data[context->dataNum]->count); } __code code3(struct Context* context, struct Node* node, struct Count* count) { if (count->i == 0) { goto meta(context, Code4); } print_tree(context->data[Tree]->tree.root, 0); puts(""); context->next = Code3; node->key = rand()%100+1; node->value = count->i; count->i--; goto meta(context, Put); } __code code3_stub(struct Context* context) { goto code3(context, &context->data[Node]->node, &context->data[3]->count); } __code code4(struct Context* context) { puts("---before---"); print_tree(context->data[Tree]->tree.root, 0); struct Node* node = &context->data[Node]->node; node->key = 4; context->next = Code5; goto meta(context, Exit); } __code code5(struct Context* context) { puts("---after---"); print_tree(context->data[Tree]->tree.root, 0); puts("--Number of Data--"); printf("%d\n", context->dataNum); goto meta(context, Exit); } __code find(struct Context* context) { context->data[Node]->node.key = 2; context->next = Not_find; goto meta(context, Get); } __code not_find(struct Context* context) { context->data[Node]->node.key = 10; context->next = Code6; printf("%p\n", context->data[Tree]->tree.current); context->data[Tree]->tree.current = 0; goto meta(context, Get); } __code code6(struct Context* context) { printf("%p\n", context->data[Tree]->tree.current); stack_free(context->node_stack); goto meta(context, Exit); } int main(int argc, char** argv) { num = (int)atoi(argv[1]); struct Context* context = (struct Context*)malloc(sizeof(struct Context)); initLLRBContext(context, num); goto start_code(context, Code1); }