From 6eda86bf38d5b9c12f6d6d7c394ee23497681c3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 14 Sep 2018 16:52:08 +0900 Subject: [PATCH] [coco] Simplify Bag-Dep relation update (#1492) 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 --- contrib/coco/core/include/coco/IR/Bag.h | 3 +++ contrib/coco/core/include/coco/IR/Dep.h | 6 ++---- contrib/coco/core/src/IR/Dep.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/Bag.h b/contrib/coco/core/include/coco/IR/Bag.h index 3ac8c03..9a0e0d1 100644 --- a/contrib/coco/core/include/coco/IR/Bag.h +++ b/contrib/coco/core/include/coco/IR/Bag.h @@ -45,6 +45,9 @@ public: using ReaderSet = std::set; public: + friend class Dep; + +public: explicit Bag(std::unique_ptr &&info); public: diff --git a/contrib/coco/core/include/coco/IR/Dep.h b/contrib/coco/core/include/coco/IR/Dep.h index ea8c493..d5a26b7 100644 --- a/contrib/coco/core/include/coco/IR/Dep.h +++ b/contrib/coco/core/include/coco/IR/Dep.h @@ -37,14 +37,12 @@ public: void object(Object *object) { _object = object; } public: - void link(const PtrLink *link) { _link = link; } + // WARN This method is deprecated + void link(const PtrLink *link) { return; } private: Bag *_bag = nullptr; Object *_object = nullptr; - -private: - const PtrLink *_link = nullptr; }; } // namespace coco diff --git a/contrib/coco/core/src/IR/Dep.cpp b/contrib/coco/core/src/IR/Dep.cpp index 6951111..d1a6d13 100644 --- a/contrib/coco/core/src/IR/Dep.cpp +++ b/contrib/coco/core/src/IR/Dep.cpp @@ -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); } -- 2.7.4