From: bdemsky Date: Thu, 28 Oct 2004 19:33:05 +0000 (+0000) Subject: Revert changes. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=commitdiff_plain;h=1a9b5106dbaf948defb63a97a3ffffde025a4e2c;ds=sidebyside Revert changes. --- diff --git a/Repair/RepairCompiler/MCC/Runtime/SimpleHash.h b/Repair/RepairCompiler/MCC/Runtime/SimpleHash.h index e87ed7b..094c963 100755 --- a/Repair/RepairCompiler/MCC/Runtime/SimpleHash.h +++ b/Repair/RepairCompiler/MCC/Runtime/SimpleHash.h @@ -1,116 +1,104 @@ #ifndef SIMPLEHASH_H #define SIMPLEHASH_H -#ifndef bool -#define bool int -#endif - -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif - +/* LinkedHashNode *****************************************************/ -#include -#include +class LinkedHashNode { + +public: + LinkedHashNode *next; + LinkedHashNode *lnext,*lprev; + int data; + int key; -/* LinkedHashNode *****************************************************/ -struct LinkedHashNode * allocateLinkedHashNode(int key, int data, struct LinkedHashNode *next); -struct LinkedHashNode * noargallocateLinkedHashNode(); + LinkedHashNode(int key, int data, LinkedHashNode *next); + LinkedHashNode(); -struct LinkedHashNode { - struct LinkedHashNode *next; - struct LinkedHashNode *lnext,*lprev; - int data; - int key; }; /* SimpleList *********************************************************/ -struct SimpleList * allocateSimpleList(); -void SimpleListadd(struct SimpleList *, int data); -int SimpleListcontains(struct SimpleList *,int data); -void SimpleListreset(struct SimpleList *); -int SimpleListhasMoreElements(struct SimpleList *); -int SimpleListnextElement(struct SimpleList *); - -struct SimpleList { - struct LinkedHashNode head; - struct LinkedHashNode *ptr; +class SimpleList { +private: + LinkedHashNode head; + LinkedHashNode *ptr; +public: + SimpleList(); + void add(int data); + int contains(int data); + void reset(); + int hasMoreElements(); + int nextElement(); }; /* WorkList *********************************************************/ #define WLISTSIZE 4*100 -struct WorkList * allocateWorkList(); -void freeWorkList(struct WorkList *); -void WorkListreset(struct WorkList *); -void WorkListadd(struct WorkList *,int id, int type, int lvalue, int rvalue); -int WorkListhasMoreElements(struct WorkList *); -int WorkListgetid(struct WorkList *); -int WorkListgettype(struct WorkList *); -int WorkListgetlvalue(struct WorkList *); -int WorkListgetrvalue(struct WorkList *); -void WorkListpop(struct WorkList *); - - -struct WorkList { +class WorkList { +private: struct ListNode *head; struct ListNode *tail; int headoffset; int tailoffset; + +public: + WorkList(); + ~WorkList(); + void reset(); + void add(int id, int type, int lvalue, int rvalue); + int hasMoreElements(); + int getid(); + int gettype(); + int getlvalue(); + int getrvalue(); + void pop(); }; struct ListNode { int data[WLISTSIZE]; - struct ListNode *next; + ListNode *next; }; - /* SimpleHash *********************************************************/ +class SimpleIterator; -struct SimpleHash * noargallocateSimpleHash(); -struct SimpleHash * allocateSimpleHash(int size); -void SimpleHashaddChild(struct SimpleHash *thisvar, struct SimpleHash * child); -void freeSimpleHash(struct SimpleHash *); - - -int SimpleHashadd(struct SimpleHash *, int key, int data); -int SimpleHashremove(struct SimpleHash *,int key, int data); -bool SimpleHashcontainskey(struct SimpleHash *,int key); -bool SimpleHashcontainskeydata(struct SimpleHash *,int key, int data); -int SimpleHashget(struct SimpleHash *,int key, int* data); -int SimpleHashcountdata(struct SimpleHash *,int data); -void SimpleHashaddParent(struct SimpleHash *,struct SimpleHash* parent); -int SimpleHashfirstkey(struct SimpleHash *); -struct SimpleIterator* SimpleHashcreateiterator(struct SimpleHash *, struct SimpleHash *); -void SimpleHashiterator(struct SimpleHash *, struct SimpleIterator * it); -int SimpleHashcount(struct SimpleHash *, int key); -void SimpleHashaddAll(struct SimpleHash *, struct SimpleHash * set); -struct SimpleHash * SimpleHashimageSet(struct SimpleHash *, int key); - -struct SimpleHash { +class SimpleHash { +private: int numelements; int size; struct SimpleNode **bucket; struct ArraySimple *listhead; struct ArraySimple *listtail; + + int numparents; int numchildren; - struct SimpleHash* parents[10]; - struct SimpleHash* children[10]; + SimpleHash* parents[10]; + SimpleHash* children[10]; + void addChild(SimpleHash* child); +public: int tailindex; + SimpleHash(int size=100); + ~SimpleHash(); + int add(int key, int data); + int remove(int key, int data); + bool contains(int key); + bool contains(int key, int data); + int get(int key, int& data); + int countdata(int data); + void addParent(SimpleHash* parent); + int firstkey(); + SimpleIterator* iterator(); + void iterator(SimpleIterator & it); + inline int count() { + return numelements; + } + int count(int key); + void addAll(SimpleHash * set); + SimpleHash * imageSet(int key); }; -inline int count(struct SimpleHash * thisvar) { - return thisvar->numelements; -} - - /* SimpleHashExcepion *************************************************/ @@ -120,7 +108,7 @@ inline int count(struct SimpleHash * thisvar) { struct SimpleNode { struct SimpleNode *next; int data; - int key; + int key; int inuse; }; @@ -130,83 +118,91 @@ struct ArraySimple { }; -struct SimpleIterator { +class SimpleIterator { + public: + struct ArraySimple *cur, *tail; int index,tailindex; -}; - -inline struct SimpleIterator * noargallocateSimpleIterator() { - return (struct SimpleIterator*)malloc(sizeof(struct SimpleIterator)); -} - -inline struct SimpleIterator * allocateSimpleIterator(struct ArraySimple *start, struct ArraySimple *tl, int tlindex) { - struct SimpleIterator *thisvar=(struct SimpleIterator*)malloc(sizeof(struct SimpleIterator)); - thisvar->cur = start; - thisvar->index=0; - thisvar->tailindex=tlindex; - thisvar->tail=tl; - return thisvar; -} - -inline int hasNext(struct SimpleIterator *thisvar) { - if (thisvar->cur==thisvar->tail && - thisvar->index==thisvar->tailindex) - return 0; - while((thisvar->index==ARRAYSIZE)||!thisvar->cur->nodes[thisvar->index].inuse) { - if (thisvar->index==ARRAYSIZE) { - thisvar->index=0; - thisvar->cur=thisvar->cur->nextarray; - } else - thisvar->index++; + // SimpleHash * table; + inline SimpleIterator() {} + + inline SimpleIterator(struct ArraySimple *start, struct ArraySimple *tl, int tlindex/*, SimpleHash *t*/) { + cur = start; + // table=t; + index=0; + tailindex=tlindex; + tail=tl; + } + + inline int hasNext() { + if (cur==tail && + index==tailindex) + return 0; + while((index==ARRAYSIZE)||!cur->nodes[index].inuse) { + if (index==ARRAYSIZE) { + index=0; + cur=cur->nextarray; + } else + index++; } - if (thisvar->cur->nodes[thisvar->index].inuse) - return 1; + if (cur->nodes[index].inuse) + return 1; else - return 0; -} - -inline int next(struct SimpleIterator *thisvar) { - return thisvar->cur->nodes[thisvar->index++].data; -} - -inline int key(struct SimpleIterator *thisvar) { - return thisvar->cur->nodes[thisvar->index].key; -} + return 0; + } + + inline int next() { + return cur->nodes[index++].data; + } + + inline int key() { + return cur->nodes[index].key; + } +}; +/* SimpleHashExcepion *************************************************/ -struct RepairHashNode * allocateRepairHashNode(int setrelation, int rule, int lvalue, int rvalue, int data, int data2,int ismodify); +class SimpleHashException { +public: + SimpleHashException(); +}; -struct RepairHashNode { - struct RepairHashNode *next; - struct RepairHashNode *lnext; +class RepairHashNode { + public: + RepairHashNode *next; + RepairHashNode *lnext; int data; int data2; - int setrelation; - int lvalue; - int rvalue; + int setrelation; + int lvalue; + int rvalue; int rule; int ismodify; + RepairHashNode(int setrelation, int rule, int lvalue, int rvalue, int data, int data2,int ismodify); }; -struct RepairHash * noargallocateRepairHash(); -struct RepairHash * allocateRepairHash(int size); -void freeRepairHash(struct RepairHash *); -int addset(struct RepairHash *, int setv, int rule, int value, int data); -int addrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data); -int addrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data, int data2); -bool containsset(struct RepairHash *, int setv, int rule, int value); -bool containsrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue); -int getset(struct RepairHash *, int setv, int rule, int value); -int getrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue); -int getrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue); -int ismodify(struct RepairHash *, int relation, int rule, int lvalue, int rvalue); - -struct RepairHash { +class RepairHash { + +private: int numelements; int size; - struct RepairHashNode **bucket; - struct RepairHashNode *nodelist; - + RepairHashNode **bucket; + RepairHashNode *nodelist; + +public: + RepairHash(); + RepairHash(int size); + ~RepairHash(); + int addset(int setv, int rule, int value, int data); + int addrelation(int relation, int rule, int lvalue, int rvalue, int data); + int addrelation(int relation, int rule, int lvalue, int rvalue, int data, int data2); + bool containsset(int setv, int rule, int value); + bool containsrelation(int relation, int rule, int lvalue, int rvalue); + int getset(int setv, int rule, int value); + int getrelation(int relation, int rule, int lvalue, int rvalue); + int getrelation2(int relation, int rule, int lvalue, int rvalue); + int ismodify(int relation, int rule, int lvalue, int rvalue); }; #endif + diff --git a/Repair/RepairCompiler/MCC/Runtime/classlist.h b/Repair/RepairCompiler/MCC/Runtime/classlist.h index c04c1af..1fbfcc7 100755 --- a/Repair/RepairCompiler/MCC/Runtime/classlist.h +++ b/Repair/RepairCompiler/MCC/Runtime/classlist.h @@ -1,4 +1,7 @@ #ifndef CLASSLIST_H #define CLASSLIST_H +class typeobject; +class typemap; +class structuremap; #endif diff --git a/Repair/RepairCompiler/MCC/Runtime/instrument.h b/Repair/RepairCompiler/MCC/Runtime/instrument.h index 7709e05..6037682 100755 --- a/Repair/RepairCompiler/MCC/Runtime/instrument.h +++ b/Repair/RepairCompiler/MCC/Runtime/instrument.h @@ -1,4 +1,4 @@ -/* Defines interfaces for the applications and exports function calls that +/* Defines interfaces for the applications and exports function calls that the applications should use instead of the standard ones. */ #ifndef INSTRUMENT_H @@ -6,10 +6,6 @@ #include "classlist.h" #include -#ifndef bool -#define bool int -#endif - void alloc(void *ptr,int size); void dealloc(void *ptr); void *ourcalloc(size_t nmemb, size_t size); @@ -17,9 +13,10 @@ void *ourmalloc(size_t size); void ourfree(void *ptr); void *ourrealloc(void *ptr, size_t size); void initializemmap(); +typeobject * gettypeobject(); void resettypemap(); bool assertvalidtype(int ptr, int structure); bool assertvalidmemory(int ptr, int structure); void initializestack(void *); -extern struct typemap * memmap; +extern typemap * memmap; #endif diff --git a/Repair/RepairCompiler/MCC/Runtime/memory.h b/Repair/RepairCompiler/MCC/Runtime/memory.h index 3a1c76b..e2fff80 100755 --- a/Repair/RepairCompiler/MCC/Runtime/memory.h +++ b/Repair/RepairCompiler/MCC/Runtime/memory.h @@ -1,7 +1,8 @@ #ifndef MEMORY_H #define MEMORY_H +extern "C" { #include "instrument.h" - +} #define malloc(size) ourmalloc(size) #define calloc(memb,size) ourcalloc(memb,size) #define realloc(ptr,size) ourrealloc(ptr,size) diff --git a/Repair/RepairCompiler/MCC/Runtime/stack.c b/Repair/RepairCompiler/MCC/Runtime/stack.c index c9586dc..838293d 100755 --- a/Repair/RepairCompiler/MCC/Runtime/stack.c +++ b/Repair/RepairCompiler/MCC/Runtime/stack.c @@ -11,7 +11,7 @@ Permission is hereby granted to use or copy this program for any purpose, provided the above notices are retained on all copies. Permission to modify the code and to distribute modified code is granted, provided the above notices are retained, and a notice that the code was -modified is included with the above copyright notice. +modified is included with the above copyright notice. */ @@ -19,9 +19,6 @@ modified is included with the above copyright notice. #include #include #include -#include -#include - #define ptr_t void * #pragma weak __libc_stack_end extern ptr_t __libc_stack_end; @@ -34,7 +31,7 @@ extern ptr_t __libc_stack_end; { /* We read the stack base value from /proc/self/stat. We do this */ /* using direct I/O system calls in order to avoid calling malloc */ - /* in case REDIRECT_MALLOC is defined. */ + /* in case REDIRECT_MALLOC is defined. */ # define STAT_BUF_SIZE 4096 # define STAT_READ read /* Should probably call the real read, if read is wrapped. */ @@ -53,7 +50,7 @@ extern ptr_t __libc_stack_end; return __libc_stack_end + 0x10; } /* Otherwise it's not safe to add 16 bytes and we fall */ /* back to using /proc. */ -# else +# else return __libc_stack_end; # endif } diff --git a/Repair/RepairCompiler/MCC/Runtime/tmap.h b/Repair/RepairCompiler/MCC/Runtime/tmap.h index 535ecc5..85f8619 100755 --- a/Repair/RepairCompiler/MCC/Runtime/tmap.h +++ b/Repair/RepairCompiler/MCC/Runtime/tmap.h @@ -1,49 +1,36 @@ #ifndef TMAP_H #define TMAP_H #include "classlist.h" -#include "redblack.h" -#ifndef bool -#define bool int -#endif - -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif - -struct typemap * allocatetypemap(); -void freetypemap(struct typemap *); -void typemapreset(struct typemap *); -void initializetypemapstack(struct typemap *, void *high); - -void typemapallocate(struct typemap *, void *, int); -void typemapdeallocate(struct typemap *, void *); -bool typemapassertvalidmemoryB(struct typemap *, void* low, void* high); -bool typemapasserttypeB(struct typemap *, void *ptr, void *high, int structure); -bool typemapassertvalidmemory(struct typemap *, void* low, int structure); -bool typemapasserttype(struct typemap *, void *ptr, int structure); -bool typemapistype(struct typemap *, void *ptr, void *high, int structure); -bool typemapcheckmemory(struct typemap *, void* low, void* high); -bool typemapchecktype(struct typemap *, bool doaction,void *ptr, int structure); -bool typemapchecktypeB(struct typemap *, bool doaction, void *low, void *high,int structure, struct rbtree *ttree); -int typemapfindoffsetstructure(struct typemap *, int s, int offset); - - -struct typemap { +class typemap { + public: + typemap(typeobject *); + ~typemap(); + void allocate(void *, int); + void deallocate(void *); + bool assertvalidmemory(void* low, void* high); + bool asserttype(void *ptr, void *high, int structure); + bool assertvalidmemory(void* low, int structure); + bool asserttype(void *ptr, int structure); + bool istype(void *ptr, void *high, int structure); + void reset(); + typeobject *size; + void initializestack(void *high); + private: void *low; void *high; + bool checkmemory(void* low, void* high); + bool checktype(bool doaction,void *ptr, int structure); + bool checktype(bool doaction, void *low, void *high,int structure, struct rbtree *ttree); + int findoffsetstructure(int s, int offset); struct rbtree *alloctree; struct rbtree *typetree; }; -struct structuremap * allocatestructuremap(int s); -void freestructuremap(struct structuremap *); - -struct structuremap { +class structuremap { + public: + structuremap(int s); + ~structuremap(); int str; struct rbtree *typetree; };