change data structures
[c11tester.git] / funcnode.cc
index 3a545112be7f3964e850f4c296ef1ede8c4ddfe5..27d57f0681c11ebd6bd7f255f72abc009bd0b2dc 100644 (file)
@@ -1,13 +1,44 @@
 #include "funcnode.h"
 
-FuncInst::FuncInst(ModelAction *act) :
-       action(act)
+FuncInst::FuncInst(ModelAction *act)
 {
        ASSERT(act);
        this->position = act->get_position();
+       this->location = act->get_location();
+       this->type = act->get_type();
 }
 
 FuncNode::FuncNode() :
        func_insts()
 {}
 
+void FuncNode::add_action(ModelAction *act)
+{
+       ASSERT(act);
+
+       const char * position = act->get_position();
+
+       /* Actions THREAD_CREATE, THREAD_START, THREAD_YIELD, THREAD_JOIN,
+        * THREAD_FINISH, PTHREAD_CREATE, PTHREAD_JOIN,
+        * ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK are not tagged with their
+        * source line numbers
+        */
+       if (position == NULL) {
+               return;
+       }
+
+       if ( func_insts.contains(position) ) {
+               FuncInst * inst = func_insts.get(position);
+
+               if (inst->get_type() != act->get_type() && 
+                       inst->get_type() != ATOMIC_RMWRCAS ) {
+                       model_print("action with a different type occurs at line number %s \n", position);
+               }
+
+               return;
+       }
+
+       FuncInst * func_inst = new FuncInst(act);
+       func_insts.put(position, func_inst);
+       inst_list.push_back(func_inst);
+}