add func_map_rev to map function ids to function names
[c11tester.git] / funcnode.cc
1 #include "funcnode.h"
2
3 FuncInst::FuncInst(ModelAction *act) :
4         collisions()
5 {
6         ASSERT(act);
7         this->position = act->get_position();
8         this->location = act->get_location();
9         this->type = act->get_type();
10 }
11
12 FuncNode::FuncNode() :
13         func_insts(),
14         inst_list(),
15         entry_insts()
16 {}
17
18 void FuncNode::add_action(ModelAction *act)
19 {
20         ASSERT(act);
21
22         const char * position = act->get_position();
23
24         /* Actions THREAD_CREATE, THREAD_START, THREAD_YIELD, THREAD_JOIN,
25          * THREAD_FINISH, PTHREAD_CREATE, PTHREAD_JOIN,
26          * ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK are not tagged with their
27          * source line numbers
28          */
29         if (position == NULL) {
30                 return;
31         }
32
33         if ( func_insts.contains(position) ) {
34                 FuncInst * inst = func_insts.get(position);
35
36                 if (inst->get_type() != act->get_type() ) {
37                         model_print("action with a different type occurs at line number %s\n", position);
38                         FuncInst * func_inst = inst->search_in_collision(act);
39
40                         if (func_inst != NULL)
41                                 return;
42
43                         func_inst = new FuncInst(act);
44                         inst->get_collisions()->push_back(func_inst);
45                         inst_list.push_back(func_inst);         // delete?
46                         model_print("collision added\n");
47                 }
48
49                 return;
50         }
51
52         FuncInst * func_inst = new FuncInst(act);
53         func_insts.put(position, func_inst);
54
55         inst_list.push_back(func_inst);
56 }