factor out codes for FuncInst class
[c11tester.git] / funcinst.cc
1 #include "funcinst.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 bool FuncInst::add_pred(FuncInst * other) {
13         func_inst_list_mt::iterator it;
14         for (it = predecessors.begin(); it != predecessors.end(); it++) {
15                 FuncInst * inst = *it;
16                 if (inst == other)
17                         return false;
18         }
19
20         predecessors.push_back(other);
21         return true;
22 }
23
24 bool FuncInst::add_succ(FuncInst * other) {
25         func_inst_list_mt::iterator it;
26         for (it = successors.begin(); it != successors.end(); it++) {
27                 FuncInst * inst = *it;
28                 if ( inst == other )
29                         return false;
30         }
31
32         successors.push_back(other);
33         return true;
34 }
35
36 FuncInst * FuncInst::search_in_collision(ModelAction *act) {
37         action_type type = act->get_type();
38
39         func_inst_list_mt::iterator it;
40         for (it = collisions.begin(); it != collisions.end(); it++) {
41                 FuncInst * inst = *it;
42                 if ( inst->get_type() == type )
43                         return inst;
44         }
45         return NULL;
46 }