cyclegraph: rename addEdge() to addNodeEdge()
[model-checker.git] / cyclegraph.h
index 5f6974b9033f3950af16f7108270bc427c2c9ce5..5c49992ea26b7dc99bc88cea4040e98c88cc3361 100644 (file)
@@ -39,7 +39,7 @@ class CycleGraph {
 
        SNAPSHOTALLOC
  private:
-       void addEdge(CycleNode *fromnode, CycleNode *tonode);
+       void addNodeEdge(CycleNode *fromnode, CycleNode *tonode);
        void putNode(const ModelAction *act, CycleNode *node);
        CycleNode * getNode(const ModelAction *);
        HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
@@ -60,31 +60,42 @@ class CycleGraph {
        std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > rmwrollbackvector;
 };
 
-/** @brief A node within a CycleGraph; corresponds to one ModelAction */
+/**
+ * @brief A node within a CycleGraph; corresponds either to one ModelAction or
+ * to a promised future value
+ */
 class CycleNode {
  public:
        CycleNode(const ModelAction *act);
+       CycleNode(const Promise *promise);
        bool addEdge(CycleNode *node);
        CycleNode * getEdge(unsigned int i) const;
        unsigned int getNumEdges() const;
        CycleNode * getBackEdge(unsigned int i) const;
        unsigned int getNumBackEdges() const;
+       CycleNode * removeEdge();
+       CycleNode * removeBackEdge();
+
        bool setRMW(CycleNode *);
        CycleNode * getRMW() const;
+       void clearRMW() { hasRMW = NULL; }
        const ModelAction * getAction() const { return action; }
 
        void popEdge() {
                edges.pop_back();
        }
-       void clearRMW() {
-               hasRMW = NULL;
-       }
+
+       bool is_promise() const { return !action; }
 
        SNAPSHOTALLOC
  private:
        /** @brief The ModelAction that this node represents */
        const ModelAction *action;
 
+       /** @brief The promise represented by this node; only valid when action
+        * is NULL */
+       const Promise *promise;
+
        /** @brief The edges leading out from this node */
        std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > edges;