[coco] Require Instr on Step construction (#1779)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 8 Oct 2018 07:33:51 +0000 (16:33 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 8 Oct 2018 07:33:51 +0000 (16:33 +0900)
This commit disables default constructor of Step, and explicitly requires
Instr on construction.

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

index 24d7a2d..31dad43 100644 (file)
@@ -29,7 +29,10 @@ namespace coco
 class Step final
 {
 public:
-  Step() = default;
+  explicit Step(Instr *instr) : _instr{instr}
+  {
+    // DO NOTHING
+  }
 
 public:
   ~Step() { op(nullptr); }
@@ -40,7 +43,6 @@ public:
 
 public:
   Instr *instr(void) const { return _instr; }
-  void instr(Instr *i) { _instr = i; }
 
 private:
   Op *_op = nullptr;
index 27a8798..66e3c78 100644 (file)
@@ -32,7 +32,10 @@ namespace coco
 class UnitF final : public FeatureInstr
 {
 public:
-  UnitF() { _step.instr(this); }
+  UnitF() : _step{this}
+  {
+    // DO NOTHING
+  }
 
 public:
   UnitF *asUnitF(void) override { return this; }
index f6a51df..23b7f9f 100644 (file)
@@ -34,7 +34,7 @@ std::set<coco::Bag *> &operator+=(std::set<coco::Bag *> &res, const coco::Object
 namespace coco
 {
 
-Eval::Eval() : _out{this}
+Eval::Eval() : _out{this}, _step{this}
 {
   // DO NOTHING
 }