Get code to compile
[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 {
22         mllnode<FuncInst*> * it;
23         for (it = predecessors.begin();it != NULL;it=it->getNext()) {
24                 FuncInst * inst = it->getVal();
25                 if (inst == other)
26                         return false;
27         }
28
29         predecessors.push_back(other);
30         return true;
31 }
32
33 bool FuncInst::add_succ(FuncInst * other)
34 {
35         mllnode<FuncInst*>* it;
36         for (it = successors.begin();it != NULL;it=it->getNext()) {
37                 FuncInst * inst = it->getVal();
38                 if ( inst == other )
39                         return false;
40         }
41
42         successors.push_back(other);
43         return true;
44 }
45
46 FuncInst * FuncInst::search_in_collision(ModelAction *act)
47 {
48         action_type type = act->get_type();
49
50         mllnode<FuncInst*>* it;
51         for (it = collisions.begin();it != NULL;it=it->getNext()) {
52                 FuncInst * inst = it->getVal();
53                 if ( inst->get_type() == type )
54                         return inst;
55         }
56         return NULL;
57 }
58
59 bool FuncInst::is_read() const
60 {
61         return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS;    /* type == ATOMIC_RMW ? */
62 }
63
64 bool FuncInst::is_write() const
65 {
66         return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == ATOMIC_UNINIT || type == NONATOMIC_WRITE;
67 }
68