add entry atomic instructions to FuncNode
[c11tester.git] / funcinst.cc
1 #include "funcinst.h"
2
3 FuncInst::FuncInst(ModelAction *act, FuncNode *func_node) :
4         collisions()
5 {
6         ASSERT(act);
7         ASSERT(func_node);
8         this->position = act->get_position();
9         this->location = act->get_location();
10         this->type = act->get_type();
11         this->func_node = func_node;
12 }
13
14 /* @param other Preceding FuncInst in the same execution trace
15  * Add other to predecessors if it has been added 
16  *
17  * @return false: other is already in predecessors
18  *         true : other is added to precedessors
19  */
20 bool FuncInst::add_pred(FuncInst * other) {
21         func_inst_list_mt::iterator it;
22         for (it = predecessors.begin(); it != predecessors.end(); it++) {
23                 FuncInst * inst = *it;
24                 if (inst == other)
25                         return false;
26         }
27
28         predecessors.push_back(other);
29         return true;
30 }
31
32 bool FuncInst::add_succ(FuncInst * other) {
33         func_inst_list_mt::iterator it;
34         for (it = successors.begin(); it != successors.end(); it++) {
35                 FuncInst * inst = *it;
36                 if ( inst == other )
37                         return false;
38         }
39
40         successors.push_back(other);
41         return true;
42 }
43
44 FuncInst * FuncInst::search_in_collision(ModelAction *act) {
45         action_type type = act->get_type();
46
47         func_inst_list_mt::iterator it;
48         for (it = collisions.begin(); it != collisions.end(); it++) {
49                 FuncInst * inst = *it;
50                 if ( inst->get_type() == type )
51                         return inst;
52         }
53         return NULL;
54 }