(1) structure code a little better
[model-checker.git] / cyclegraph.cc
index 967b0763abbdcdba0ec35cdd2608cb0fa94caa13..f519dac93b39975742887746f79a194e63dd12fe 100644 (file)
@@ -1,5 +1,6 @@
 #include "cyclegraph.h"
 #include "action.h"
+#include "common.h"
 
 /** Initializes a CycleGraph object. */
 CycleGraph::CycleGraph() :
@@ -33,6 +34,9 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) {
  * @param from The edge comes from this ModelAction
  */
 void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
+       ASSERT(from);
+       ASSERT(to);
+
        CycleNode *fromnode=getNode(from);
        CycleNode *tonode=getNode(to);
 
@@ -65,6 +69,9 @@ void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
  *  action can read from a given write.
  */
 void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
+       ASSERT(from);
+       ASSERT(rmw);
+
        CycleNode *fromnode=getNode(from);
        CycleNode *rmwnode=getNode(rmw);
 
@@ -133,6 +140,12 @@ bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) {
        return false;
 }
 
+void CycleGraph::startChanges() {
+       ASSERT(rollbackvector.size()==0);
+       ASSERT(rmwrollbackvector.size()==0);
+       ASSERT(oldCycles==hasCycles);
+}
+
 /** Commit changes to the cyclegraph. */
 void CycleGraph::commitChanges() {
        rollbackvector.resize(0);