[coco] Maintain UpdateSet instead of UpdaterSet (#1437)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 11 Sep 2018 02:58:11 +0000 (11:58 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 11 Sep 2018 02:58:11 +0000 (11:58 +0900)
This commit rewrites BagInfo to maintain UpdateSet instead of
UpdaterSet, which is necessary to support Bag-to-Bag substitution.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/BagInfo.h
contrib/coco/core/include/coco/IR/UpdateSet.h [new file with mode: 0644]
contrib/coco/core/src/IR/Bag.cpp
contrib/coco/core/src/IR/Update.cpp

index 5ac23f9..626f342 100644 (file)
@@ -4,6 +4,7 @@
 #include "coco/IR/Bag.h"
 #include "coco/IR/DepSet.h"
 #include "coco/IR/ReadSet.h"
+#include "coco/IR/UpdateSet.h"
 
 #include <set>
 
@@ -64,8 +65,8 @@ public:
   const ReadSet *reads(void) const { return &_reads; }
 
 public:
-  Bag::UpdaterSet *updates(void) { return &_updates; }
-  const Bag::UpdaterSet *updates(void) const { return &_updates; }
+  UpdateSet *updates(void) { return &_updates; }
+  const UpdateSet *updates(void) const { return &_updates; }
 
 public:
   BagMask *mask(void) { return &_mask; }
@@ -77,7 +78,7 @@ private:
   /** @brief Direct reads (not through Object) */
   ReadSet _reads;
   /** @brief Direct updates (not through Object) */
-  Bag::UpdaterSet _updates;
+  UpdateSet _updates;
 
   BagMask _mask;
 };
diff --git a/contrib/coco/core/include/coco/IR/UpdateSet.h b/contrib/coco/core/include/coco/IR/UpdateSet.h
new file mode 100644 (file)
index 0000000..ae36245
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __COCO_IR_UPDATE_SET_H__
+#define __COCO_IR_UPDATE_SET_H__
+
+#include "coco/IR/Update.h"
+
+#include <set>
+
+namespace coco
+{
+
+using UpdateSet = std::set<Update *>;
+
+} // namespace coco
+
+#endif // __COCO_IR_UPDATE_SET_H__
index 2149455..8540dc1 100644 (file)
@@ -74,7 +74,9 @@ Bag::UpdaterSet Bag::updates(void) const
 
   for (auto update : *_info->updates())
   {
-    res.insert(update);
+    auto updater = update->updater();
+    assert(updater != nullptr);
+    res.insert(updater);
   }
 
   return res;
index 6e0cf45..709b1ba 100644 (file)
@@ -10,11 +10,11 @@ void Update::bag(Bag *bag)
 {
   if (_bag)
   {
-    if (_link && _updater)
+    if (_link)
     {
       auto info = _link->find(_bag);
       assert(info != nullptr);
-      info->updates()->erase(_updater);
+      info->updates()->erase(this);
     }
     _bag = nullptr;
   }
@@ -24,11 +24,11 @@ void Update::bag(Bag *bag)
   if (bag)
   {
     _bag = bag;
-    if (_link && _updater)
+    if (_link)
     {
       auto info = _link->find(_bag);
       assert(info != nullptr);
-      info->updates()->insert(_updater);
+      info->updates()->insert(this);
     }
   }