This commit adds 'Subsscript' class under nest::expr namespace, which
denotes a ND domain subscript expression.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
--- /dev/null
+#ifndef __NEST_SUBSCRIPT_H__
+#define __NEST_SUBSCRIPT_H__
+
+#include "nest/expr/Node.h"
+
+#include <vector>
+
+#include <memory>
+
+namespace nest
+{
+namespace expr
+{
+
+class Subscript
+{
+public:
+ template <typename... Args>
+ Subscript(Args &&... indicies) : _indices{std::forward<Args>(indicies)...}
+ {
+ // DO NOTHING
+ }
+
+public:
+ uint32_t rank(void) const { return _indices.size(); }
+
+public:
+ const std::shared_ptr<expr::Node> &at(uint32_t n) const { return _indices.at(n); }
+
+private:
+ std::vector<std::shared_ptr<expr::Node>> const _indices;
+};
+
+} // namespace expr
+} // namespace nest
+
+#endif // __NEST_SUBSCRIPT_H__
--- /dev/null
+#include "nest/expr/Subscript.h"
+#include "nest/expr/VarNode.h"
+
+#include <memory>
+
+#include <gtest/gtest.h>
+
+TEST(SUBSCRIPT, ctor)
+{
+ nest::VarID id_0{0};
+ nest::VarID id_1{1};
+
+ auto expr_0 = std::make_shared<nest::expr::VarNode>(id_0);
+ auto expr_1 = std::make_shared<nest::expr::VarNode>(id_1);
+
+ nest::expr::Subscript sub{expr_0, expr_1};
+
+ ASSERT_EQ(sub.rank(), 2);
+ ASSERT_EQ(sub.at(0), expr_0);
+ ASSERT_EQ(sub.at(1), expr_1);
+}