change data structures
[c11tester.git] / funcnode.cc
1 #include "funcnode.h"
2
3 FuncInst::FuncInst(ModelAction *act)
4 {
5         ASSERT(act);
6         this->position = act->get_position();
7         this->location = act->get_location();
8         this->type = act->get_type();
9 }
10
11 FuncNode::FuncNode() :
12         func_insts()
13 {}
14
15 void FuncNode::add_action(ModelAction *act)
16 {
17         ASSERT(act);
18
19         const char * position = act->get_position();
20
21         /* Actions THREAD_CREATE, THREAD_START, THREAD_YIELD, THREAD_JOIN,
22          * THREAD_FINISH, PTHREAD_CREATE, PTHREAD_JOIN,
23          * ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK are not tagged with their
24          * source line numbers
25          */
26         if (position == NULL) {
27                 return;
28         }
29
30         if ( func_insts.contains(position) ) {
31                 FuncInst * inst = func_insts.get(position);
32
33                 if (inst->get_type() != act->get_type() && 
34                         inst->get_type() != ATOMIC_RMWRCAS ) {
35                         model_print("action with a different type occurs at line number %s \n", position);
36                 }
37
38                 return;
39         }
40
41         FuncInst * func_inst = new FuncInst(act);
42         func_insts.put(position, func_inst);
43         inst_list.push_back(func_inst);
44 }