From 84d49e8de1334a7dad25864c5ba8827de2502947 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 28 Jan 2013 18:48:46 -0800 Subject: [PATCH] cyclegraph: map Promises to Promise nodes --- cyclegraph.cc | 20 ++++++++++++++++++++ cyclegraph.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/cyclegraph.cc b/cyclegraph.cc index 49c462f..58cb79f 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -47,6 +47,26 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) } /** + * @brief Returns a CycleNode corresponding to a promise + * + * Gets (or creates, if none exist) a CycleNode corresponding to a promised + * value. + * + * @param promise The Promise generated by a reader + * @return The CycleNode corresponding to the Promise + */ +CycleNode * CycleGraph::getNode(const Promise *promise) +{ + const ModelAction *reader = promise->get_action(); + CycleNode *node = readerToPromiseNode.get(reader); + if (node == NULL) { + node = new CycleNode(promise); + readerToPromiseNode.put(reader, node); + } + return node; +} + +/* * @brief Adds an edge between objects * * This function will add an edge between any two objects which can be diff --git a/cyclegraph.h b/cyclegraph.h index f812e24..4a3d083 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -45,10 +45,16 @@ class CycleGraph { void addNodeEdge(CycleNode *fromnode, CycleNode *tonode); void putNode(const ModelAction *act, CycleNode *node); CycleNode * getNode(const ModelAction *); + CycleNode * getNode(const Promise *promise); + HashTable *discovered; /** @brief A table for mapping ModelActions to CycleNodes */ HashTable actionToNode; + /** @brief A table for mapping reader ModelActions to Promise + * CycleNodes */ + HashTable readerToPromiseNode; + #if SUPPORT_MOD_ORDER_DUMP std::vector nodeList; #endif -- 2.34.1