Revert changes.
authorbdemsky <bdemsky>
Thu, 28 Oct 2004 19:33:05 +0000 (19:33 +0000)
committerbdemsky <bdemsky>
Thu, 28 Oct 2004 19:33:05 +0000 (19:33 +0000)
Repair/RepairCompiler/MCC/Runtime/SimpleHash.h
Repair/RepairCompiler/MCC/Runtime/classlist.h
Repair/RepairCompiler/MCC/Runtime/instrument.h
Repair/RepairCompiler/MCC/Runtime/memory.h
Repair/RepairCompiler/MCC/Runtime/stack.c
Repair/RepairCompiler/MCC/Runtime/tmap.h

index e87ed7b655ef024acde9beccda0f7b4507a4ab03..094c963d2c246e05c9e81706b0df6cf50a9d7cab 100755 (executable)
 #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 <stdarg.h>
-#include <stdlib.h>
+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
+
index c04c1af64a956af949359dbc51d7cea866033b5d..1fbfcc7f719b4d507dd798e9c6cbc40068982c48 100755 (executable)
@@ -1,4 +1,7 @@
 #ifndef CLASSLIST_H
 #define CLASSLIST_H
 
+class typeobject;
+class typemap;
+class structuremap;
 #endif
index 7709e054da092fe22117ad83170a6215104fc753..60376821f86d731947db26702b15f8f87d0685a0 100755 (executable)
@@ -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 <stdlib.h>
 
-#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
index 3a1c76b81fcb1e4c350c7825458236e945b002f8..e2fff80406e8ebe971787df67880f21716c4b66a 100755 (executable)
@@ -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)
index c9586dc54d84b63ed3171e31ad1d510745b76a6f..838293d642c3dfd2baa3a9153a8d9a40dfe4b523 100755 (executable)
@@ -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 <sys/stat.h>
 #include <fcntl.h>
 #include <ctype.h>
-#include <stdio.h>
-#include <unistd.h>
-
 #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
       }
index 535ecc56ec383f9d984560795c820f0de3d57852..85f8619f044d5acc251178c42e3133470578f97d 100755 (executable)
@@ -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;
 };