This commit introduces replaceAllDepsWith method in Bag.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
// NOTE reaplceWith(b) works correctly only when b is neither Input nor Output
void replaceWith(Bag *b);
+ // @brief Replace all the occurence of a bag in Object with another bag
+ //
+ // NOTE Unlike replaceWith(b), replaceAllDepsWith(b) has no restriction
+ void replaceAllDepsWith(Bag *);
+
private:
std::unique_ptr<BagInfo> _info;
};
ASSERT_EQ(shuffle_1->into(), bag_1);
ASSERT_EQ(shuffle_2->from(), bag_1);
+ bag_1->replaceAllDepsWith(bag_2);
+
+ ASSERT_EQ(obj->bag(), bag_2);
+ ASSERT_EQ(shuffle_1->into(), bag_1);
+ ASSERT_EQ(shuffle_2->from(), bag_1);
+
bag_1->replaceWith(bag_2);
ASSERT_EQ(obj->bag(), bag_2);
{
assert(!isInput() && !isOutput());
- // Replace all the occurence inside Dep
- while (!(deps()->empty()))
- {
- auto dep = *(deps()->begin());
- assert(dep->bag() == this);
- dep->bag(b);
- }
-
+ replaceAllDepsWith(b);
// Replace all the occurence inside Read
while (!(reads()->empty()))
{
assert(updates()->empty());
}
+void Bag::replaceAllDepsWith(Bag *b)
+{
+ // Replace all the occurence inside Dep
+ while (!(deps()->empty()))
+ {
+ auto dep = *(deps()->begin());
+ assert(dep->bag() == this);
+ dep->bag(b);
+ }
+}
+
ObjectSet dependent_objects(const Bag *b)
{
ObjectSet res;