[coco] Simplify Bag-Dep relation update (#1492)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 14 Sep 2018 07:52:08 +0000 (16:52 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 14 Sep 2018 07:52:08 +0000 (16:52 +0900)
This commit simplifies Bag-Dep relation updates via friend declaration.

Now, Dep does not use Bag-to-BagInfo link for relation update.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/Bag.h
contrib/coco/core/include/coco/IR/Dep.h
contrib/coco/core/src/IR/Dep.cpp

index 3ac8c03..9a0e0d1 100644 (file)
@@ -45,6 +45,9 @@ public:
   using ReaderSet = std::set<Reader *>;
 
 public:
+  friend class Dep;
+
+public:
   explicit Bag(std::unique_ptr<BagInfo> &&info);
 
 public:
index ea8c493..d5a26b7 100644 (file)
@@ -37,14 +37,12 @@ public:
   void object(Object *object) { _object = object; }
 
 public:
-  void link(const PtrLink<Bag, BagInfo> *link) { _link = link; }
+  // WARN This method is deprecated
+  void link(const PtrLink<Bag, BagInfo> *link) { return; }
 
 private:
   Bag *_bag = nullptr;
   Object *_object = nullptr;
-
-private:
-  const PtrLink<Bag, BagInfo> *_link = nullptr;
 };
 
 } // namespace coco
index 6951111..d1a6d13 100644 (file)
@@ -13,10 +13,10 @@ void Dep::bag(Bag *bag)
 {
   if (_bag != nullptr)
   {
-    // Remove bag <-> dep link (if possible)
-    if (_link)
+    // Remove bag <-> dep link
+    // TODO Remove unnecessary indentation
     {
-      auto info = _link->find(_bag);
+      auto info = _bag->_info.get();
       assert(info != nullptr);
       assert(info->deps()->find(this) != info->deps()->end());
 
@@ -34,10 +34,10 @@ void Dep::bag(Bag *bag)
     // Set _bag
     _bag = bag;
 
-    // Create bag <-> dep link (if possible)
-    if (_link)
+    // Create bag <-> dep link
+    // TODO Remove unnecessary indentation
     {
-      auto info = _link->find(bag);
+      auto info = _bag->_info.get();
       assert(info != nullptr);
       info->deps()->insert(this);
     }