From 7102566a614d8598fff55718335b91ff08b7a777 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: Wed, 19 Sep 2018 13:20:12 +0900 Subject: [PATCH] [coco] Mark mutable fields as private (#1560) This commit marks deps, reads, and updates methods in Bag as private after renaming. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Bag.h | 22 ++++++++++++++++++---- contrib/coco/core/src/IR/Dep.cpp | 4 ++-- contrib/coco/core/src/IR/Read.cpp | 4 ++-- contrib/coco/core/src/IR/Update.cpp | 4 ++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/Bag.h b/contrib/coco/core/include/coco/IR/Bag.h index 296f9fe..de433d8 100644 --- a/contrib/coco/core/include/coco/IR/Bag.h +++ b/contrib/coco/core/include/coco/IR/Bag.h @@ -88,13 +88,27 @@ public: // NOTE Unlike replaceWith(b), replaceAllDepsWith(b) has no restriction void replaceAllDepsWith(Bag *); -public: +private: + // "mutable_" prefix is deliberately introduced below to avoid resolution issue. + // + // Let's assume that two "deps" are overloaded in Bag as follows: + // class Bag + // { + // private: + // DepSet *deps(void); <-- 1 + // public: + // const DepSet *deps(void) const; <-- 2 + // }; + // + // C++ compiler tries to invoke method 1 unless a bag itself is const. Thus, any "deps" calls + // over non-const bags except those calls from friend classes will introduce build error. + // WARN Only Dep is allowed to access this method - DepSet *deps(void) { return &_deps; } + DepSet *mutable_deps(void) { return &_deps; } // WARN Only Read is allowed to access this method - ReadSet *reads(void) { return &_reads; } + ReadSet *mutable_reads(void) { return &_reads; } // WARN Only Update is allowed to access this method - UpdateSet *updates(void) { return &_updates; } + UpdateSet *mutable_updates(void) { return &_updates; } private: // WARN Only Input is allowed to access this method diff --git a/contrib/coco/core/src/IR/Dep.cpp b/contrib/coco/core/src/IR/Dep.cpp index 4dccba8..22d18d4 100644 --- a/contrib/coco/core/src/IR/Dep.cpp +++ b/contrib/coco/core/src/IR/Dep.cpp @@ -16,7 +16,7 @@ void Dep::bag(Bag *bag) // TODO Remove unnecessary indentation { assert(_bag->deps()->find(this) != _bag->deps()->end()); - _bag->deps()->erase(this); + _bag->mutable_deps()->erase(this); } // Reset _bag @@ -33,7 +33,7 @@ void Dep::bag(Bag *bag) // Create bag <-> dep link // TODO Remove unnecessary indentation { - _bag->deps()->insert(this); + _bag->mutable_deps()->insert(this); } } diff --git a/contrib/coco/core/src/IR/Read.cpp b/contrib/coco/core/src/IR/Read.cpp index 10f04af..c3e626d 100644 --- a/contrib/coco/core/src/IR/Read.cpp +++ b/contrib/coco/core/src/IR/Read.cpp @@ -17,7 +17,7 @@ void Read::bag(Bag *bag) { // TODO Remove unnecessary indentation { - _bag->reads()->erase(this); + _bag->mutable_reads()->erase(this); } _bag = nullptr; } @@ -29,7 +29,7 @@ void Read::bag(Bag *bag) _bag = bag; // TODO Remove unnecessary indentation { - _bag->reads()->insert(this); + _bag->mutable_reads()->insert(this); } } diff --git a/contrib/coco/core/src/IR/Update.cpp b/contrib/coco/core/src/IR/Update.cpp index 57a8435..4695c4f 100644 --- a/contrib/coco/core/src/IR/Update.cpp +++ b/contrib/coco/core/src/IR/Update.cpp @@ -17,7 +17,7 @@ void Update::bag(Bag *bag) { // TODO Remove unnecessary indentation { - _bag->updates()->erase(this); + _bag->mutable_updates()->erase(this); } _bag = nullptr; } @@ -29,7 +29,7 @@ void Update::bag(Bag *bag) _bag = bag; // TODO Remove unnecessary indentation { - _bag->updates()->insert(this); + _bag->mutable_updates()->insert(this); } } -- 2.7.4