factor out codes for FuncInst class
[c11tester.git] / funcnode.h
index 25e22083cae0ad0e46f67e2c681b6bdf3ce0f51f..eb7bc7946cb7b6191d6dc2bbd660049332272be6 100644 (file)
@@ -1,53 +1,20 @@
 #include "action.h"
+#include "funcinst.h"
 #include "hashtable.h"
 
 class ModelAction;
 
-typedef ModelList<FuncInst *> func_inst_list_t;
-
-class FuncInst {
-public:
-       FuncInst(ModelAction *act);
-       ~FuncInst();
-
-       //ModelAction * get_action() const { return action; }
-       const char * get_position() const { return position; }
-       void * get_location() const { return location; }
-       action_type get_type() const { return type; }
-
-       func_inst_list_t * get_collisions() { return &collisions; }
-
-       FuncInst * search_in_collision(ModelAction *act) {
-               action_type type = act->get_type();
-
-               func_inst_list_t::iterator it;
-               for (it = collisions.begin(); it != collisions.end(); it++) {
-                       FuncInst * inst = *it;
-                       if ( inst->get_type() == type )
-                               return inst;
-               }
-               return NULL;
-       }
-
-       MEMALLOC
-private:
-       //ModelAction * const action;
-       const char * position;
-       void *location;
-       action_type type;
-
-       func_inst_list_t collisions;
-};
+typedef ModelList<FuncInst *> func_inst_list_mt;
 
 class FuncNode {
 public:
        FuncNode();
        ~FuncNode();
 
-       void add_action(ModelAction *act);
+       FuncInst * get_or_add_action(ModelAction *act);
 
        HashTable<const char *, FuncInst *, uintptr_t, 4, model_malloc, model_calloc, model_free> * getFuncInsts() { return &func_insts; }
-       func_inst_list_t * get_inst_list() { return &inst_list; }
+       func_inst_list_mt * get_inst_list() { return &inst_list; }
 
        uint32_t get_func_id() { return func_id; }
        const char * get_func_name() { return func_name; }
@@ -68,8 +35,8 @@ private:
        HashTable<const char *, FuncInst *, uintptr_t, 4, model_malloc, model_calloc, model_free> func_insts;
 
        /* list of all atomic instructions in this function */
-       func_inst_list_t inst_list;
+       func_inst_list_mt inst_list;
 
        /* possible entry (atomic) instructions in this function */
-       func_inst_list_t entry_insts;
+       func_inst_list_mt entry_insts;
 };