Get rid of annoying errors and fix crazy hash function
authorbdemsky <bdemsky@uci.edu>
Fri, 30 Jun 2017 22:39:22 +0000 (15:39 -0700)
committerbdemsky <bdemsky@uci.edu>
Fri, 30 Jun 2017 22:39:22 +0000 (15:39 -0700)
src/AST/predicate.c
src/Backend/satencoder.c
src/Collections/hashset.h
src/Collections/hashtable.h
src/Collections/structs.c
src/Collections/structs.h

index 97bbd1818b5f57027ed7eab07c61f0fb46d19c9d..ebb3c14f1c8650f411c259e2699ad11ce1f2fc09 100644 (file)
@@ -13,7 +13,7 @@ Predicate* allocPredicateTable(Table* table, UndefinedBehavior undefBehavior){
        GETPREDICATETYPE(predicate) = TABLEPRED;
        predicate->table=table;
        predicate->undefinedbehavior=undefBehavior;
-       return predicate;
+       return &predicate->base;
 }
 
 void deletePredicate(Predicate* predicate){
index 9fd551985ebbaf39848d73218e3160425a2396e8..397512148f0470728fb7e0ec8a8ee6aafdd0c62c 100644 (file)
@@ -187,9 +187,9 @@ Constraint * encodeTotalOrderSATEncoder(SATEncoder *This, BooleanOrder * boolOrd
                uint size= getSizeVectorBoolean(orderConstrs);
                for(uint i=0; i<size; i++){
                        ASSERT(GETBOOLEANTYPE( getVectorBoolean(orderConstrs, i)) == ORDERCONST );
-                       BooleanOrder* tmp = (BooleanPredicate*)getVectorBoolean(orderConstrs, i);
+                       BooleanOrder* tmp = (BooleanOrder*)getVectorBoolean(orderConstrs, i);
                        BooleanOrder* newBool;
-                       Constraint* first, second;
+                       Constraint* first, *second;
                        if(tmp->second==boolOrder->first){
                                newBool = (BooleanOrder*)allocBooleanOrder(tmp->order,tmp->first,boolOrder->second);
                                first = encodeTotalOrderSATEncoder(This, tmp);
index a0f0c9ead717456e6fedbc14104442d463a4d2b5..0fe13862dfc2917684f4cc6e20cdb00a147cc8e2 100644 (file)
@@ -11,7 +11,7 @@
 #define HASH_SET_H
 #include "hashtable.h"
 
-#define HashSetDef(Name, _Key, hash_function, equals)                   \
+#define HashSetDef(Name, _Key)                                                                                                                                                                 \
        struct LinkNode ## Name {                                             \
                _Key key;                                                           \
                struct LinkNode ## Name *prev;                                      \
@@ -26,7 +26,7 @@
                HashSet ## Name * set;                                              \
        };                                                                    \
        typedef struct HSIterator ## Name HSIterator ## Name;                 \
-       HashTableDef(Name ## Set, _Key, LinkNode ## Name *, hash_function, equals); \
+       HashTableDef(Name ## Set, _Key, LinkNode ## Name *);                                                                    \
        HSIterator ## Name * allocHSIterator ## Name(LinkNode ## Name *_curr, HashSet ## Name * _set); \
        void deleteIter ## Name(HSIterator ## Name *hsit);                      \
        bool hasNext ## Name(HSIterator ## Name *hsit);                       \
index f4610d05eeaa7398d9dd2bbf56ddb8dd08650f8e..b7c78d94bb6142b60c180bf7c65a8532a59c7b8d 100644 (file)
@@ -34,7 +34,7 @@
  * @tparam _Key    Type name for the key
  * @tparam _Val    Type name for the values to be stored
  */
-#define HashTableDef(Name, _Key, _Val, hash_function, equals)\
+#define HashTableDef(Name, _Key, _Val)\
        struct hashlistnode ## Name {                                         \
                _Key key;                                                             \
                _Val val;                                                             \
index 48886ac0fabe2ee1c451abdc5262b9fd32066f3b..6fd7ceaa804e63c973074be135d796c36a75b184 100644 (file)
@@ -1,5 +1,6 @@
 #include "structs.h"
 #include "mymemory.h"
+#include "order.h"
 
 VectorImpl(Table, Table *, 4);
 VectorImpl(Set, Set *, 4);
@@ -13,4 +14,20 @@ VectorImpl(TableEntry, TableEntry *, 4);
 VectorImpl(ASTNode, ASTNode *, 4);
 VectorImpl(Int, uint64_t, 4);
 
+inline unsigned int Ptr_hash_function(void * hash) {
+       return (unsigned int)((uint64_t)hash >> 4);
+}
+
+inline bool Ptr_equals(void * key1, void * key2) {
+       return key1 == key2;
+}
+
+inline unsigned int BooleanOrder_hash_Function(BooleanOrder* This){
+       return This->first ^ This->second;
+}
+
+inline unsigned int BooleanOrder_equals(BooleanOrder* key1, BooleanOrder* key2){
+       return key1->first== key2->first && key1->second == key2->second;
+}
+
 HashTableImpl(BoolConst, BooleanOrder *, Constraint *, BooleanOrder_hash_Function, BooleanOrder_equals);
index 1ae5f8ca9eabdfe0f56f7b844bc5bb4208bdd841..86db3ed684870419f3f11fed102056a8c1256d5b 100644 (file)
@@ -24,25 +24,10 @@ VectorDef(ASTNode, ASTNode *, 4);
 VectorDef(Int, uint64_t, 4);
 
 
-inline unsigned int Ptr_hash_function(void * hash) {
-       return (unsigned int)((uint64_t)hash >> 4);
-}
 
-inline bool Ptr_equals(void * key1, void * key2) {
-       return key1 == key2;
-}
+HashTableDef(Void, void *, void *);
+HashTableDef(BoolConst, BooleanOrder *, Constraint *);
 
-inline unsigned int BooleanOrder_hash_Function(BooleanOrder* This){
-       return ((This->first+This->second)(This->first+This->second+1))/2 + This->second;
-}
-
-inline unsigned int BooleanOrder_equals(BooleanOrder* key1, BooleanOrder* key2){
-       return key1->first== key2->first && key1->second == key2->second;
-}
-
-HashTableDef(Void, void *, void *, Ptr_hash_function, Ptr_equals);
-HashTableDef(BoolConst, BooleanOrder *, Constraint *, BooleanOrder_hash_Function, BooleanOrder_equals);
-
-HashSetDef(Void, void *, Ptr_hash_function, Ptr_equals);
+HashSetDef(Void, void *);
 
 #endif