action: add create_cv() and read_from()
[model-checker.git] / action.cc
index 1fe4c7fb79d11d627a8adeccc0ae3293eb2ea11c..b0d8fc9b7bed4aaacc843cc8620c0abfffc1dd00 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -3,6 +3,7 @@
 #include "model.h"
 #include "action.h"
 #include "clockvector.h"
+#include "common.h"
 
 ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value)
 {
@@ -81,6 +82,23 @@ bool ModelAction::is_dependent(ModelAction *act)
        return false;
 }
 
+void ModelAction::create_cv(ModelAction *parent)
+{
+       ASSERT(cv == NULL);
+       if (parent)
+               cv = new ClockVector(parent->cv, this);
+       else
+               cv = new ClockVector();
+}
+
+void ModelAction::read_from(ModelAction *act)
+{
+       ASSERT(cv);
+       if (act->is_release() && this->is_acquire())
+               cv->merge(act->cv);
+       value = act->value;
+}
+
 void ModelAction::print(void)
 {
        const char *type_str;