4 Patch::Patch(const ModelAction *act, memory_order mo) {
5 PatchUnit *unit = new PatchUnit(act, mo);
6 units = new SnapVector<PatchUnit*>;
7 units->push_back(unit);
10 Patch::Patch(const ModelAction *act1, memory_order mo1, const ModelAction *act2, memory_order mo2) {
11 units = new SnapVector<PatchUnit*>;
12 PatchUnit *unit = new PatchUnit(act1, mo1);
13 units->push_back(unit);
14 unit = new PatchUnit(act2, mo2);
15 units->push_back(unit);
19 units = new SnapVector<PatchUnit*>;
22 bool Patch::canStrengthen(Inference *curInfer) {
26 for (unsigned i = 0; i < units->size(); i++) {
27 PatchUnit *u = (*units)[i];
28 memory_order wildcard = u->getAct()->get_original_mo();
29 memory_order curMO = (*curInfer)[get_wildcard_id(wildcard)];
30 if (u->getMO() != curMO)
36 bool Patch::isApplicable() {
37 for (unsigned i = 0; i < units->size(); i++) {
38 PatchUnit *u = (*units)[i];
39 memory_order wildcard = u->getAct()->get_original_mo();
40 if (is_wildcard(wildcard))
42 int compVal = Inference::compareMemoryOrder(wildcard, u->getMO());
43 if (compVal == 2 || compVal == -1)
49 void Patch::addPatchUnit(const ModelAction *act, memory_order mo) {
50 PatchUnit *unit = new PatchUnit(act, mo);
51 units->push_back(unit);
54 int Patch::getSize() {
58 PatchUnit* Patch::get(int i) {
63 for (unsigned i = 0; i < units->size(); i++) {
64 PatchUnit *u = (*units)[i];
65 model_print("wildcard %d -> %s\n",
66 get_wildcard_id_zero(u->getAct()->get_original_mo()),
67 get_mo_str(u->getMO()));