[coco] Direct update on ReadSet (#1496)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 17 Sep 2018 00:21:50 +0000 (09:21 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 17 Sep 2018 00:21:50 +0000 (09:21 +0900)
This commit declares Read as a friend class of Bag, and updates ReadSet
in it without using Bag-to-BagInfo link.

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

index 9a0e0d1..f52ec03 100644 (file)
@@ -46,6 +46,7 @@ public:
 
 public:
   friend class Dep;
+  friend class Read;
 
 public:
   explicit Bag(std::unique_ptr<BagInfo> &&info);
index f4723eb..f7bc24c 100644 (file)
@@ -15,10 +15,11 @@ namespace coco
 class Read final
 {
 public:
-  Read(const PtrLink<Bag, BagInfo> *bag_link, Bag::Reader *r)
+  // NOTE bag_link is unnecessary
+  // TODO Rewrite constructor
+  Read(const PtrLink<Bag, BagInfo> *, Bag::Reader *r)
   {
     // Initialize link and reader
-    link(bag_link);
     reader(r);
   }
 
@@ -33,12 +34,6 @@ public:
   Bag::Reader *reader(void) const { return _reader; }
   void reader(Bag::Reader *r) { _reader = r; }
 
-public:
-  void link(const PtrLink<Bag, BagInfo> *l) { _link = l; }
-
-private:
-  const PtrLink<Bag, BagInfo> *_link;
-
 private:
   Bag *_bag = nullptr;
   Bag::Reader *_reader = nullptr;
index c45022c..66b5334 100644 (file)
@@ -16,9 +16,9 @@ void Read::bag(Bag *bag)
 {
   if (_bag)
   {
-    if (_link)
+    // TODO Remove unnecessary indentation
     {
-      auto info = _link->find(_bag);
+      auto info = _bag->_info.get();
       assert(info != nullptr);
       info->reads()->erase(this);
     }
@@ -30,9 +30,9 @@ void Read::bag(Bag *bag)
   if (bag)
   {
     _bag = bag;
-    if (_link)
+    // TODO Remove unnecessary indentation
     {
-      auto info = _link->find(_bag);
+      auto info = _bag->_info.get();
       assert(info != nullptr);
       info->reads()->insert(this);
     }