[nest] Add 'Ret' class (#717)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 19 Jul 2018 05:42:00 +0000 (14:42 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 19 Jul 2018 05:42:00 +0000 (14:42 +0900)
This commit adds 'Ret' class which records where to return the compute
value.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/nest/include/nest/Ret.h [new file with mode: 0644]
contrib/nest/src/Ret.test.cpp [new file with mode: 0644]

diff --git a/contrib/nest/include/nest/Ret.h b/contrib/nest/include/nest/Ret.h
new file mode 100644 (file)
index 0000000..7abb003
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __NEST_RET_H__
+#define __NEST_RET_H__
+
+#include "nest/DomainID.h"
+#include "nest/Expr.h"
+
+namespace nest
+{
+
+class Ret
+{
+public:
+  Ret(const DomainID &id, const expr::Subscript &sub) : _id{id}, _sub{sub}
+  {
+    // DO NOTHING
+  }
+
+public:
+  const DomainID &id(void) const { return _id; }
+  const expr::Subscript &sub(void) const { return _sub; }
+
+private:
+  DomainID const _id;
+  expr::Subscript const _sub;
+};
+
+} // namespace nest
+
+#endif // __NEST_RET_H__
diff --git a/contrib/nest/src/Ret.test.cpp b/contrib/nest/src/Ret.test.cpp
new file mode 100644 (file)
index 0000000..11560e5
--- /dev/null
@@ -0,0 +1,21 @@
+#include "nest/Ret.h"
+
+#include <gtest/gtest.h>
+
+namespace
+{
+struct DummyNode final : public nest::expr::Node
+{
+};
+}
+
+TEST(RET, ctor)
+{
+  nest::DomainID dom_id{0};
+  nest::expr::Subscript sub{std::make_shared<DummyNode>()};
+
+  nest::Ret ret{dom_id, sub};
+
+  ASSERT_EQ(ret.id().value(), 0);
+  ASSERT_EQ(ret.sub().rank(), 1);
+}