This commit adds 'Block' class which maintains a sequence of nest
statements.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
--- /dev/null
+#ifndef __NEST_BLOCK_H__
+#define __NEST_BLOCK_H__
+
+#include "nest/Stmt.h"
+
+#include <vector>
+
+#include <cstdint>
+
+namespace nest
+{
+
+struct Block
+{
+public:
+ uint32_t size(void) const { return _stmts.size(); }
+
+public:
+ const Stmt &at(uint32_t n) const { return _stmts.at(n); }
+
+public:
+ void append(const Stmt &stmt) { _stmts.emplace_back(stmt); }
+
+private:
+ std::vector<Stmt> _stmts;
+};
+
+} // namespace nest
+
+#endif // __NEST_BLOCK_H__
#include "nest/stmt/Node.h"
#include "nest/stmt/Visitor.h"
+#include <memory>
+
+namespace nest
+{
+
+using Stmt = std::shared_ptr<stmt::Node>;
+
+} // namespace nest
+
#endif // __NEST_STMT_H__
--- /dev/null
+#include "nest/Block.h"
+
+#include <gtest/gtest.h>
+
+namespace
+{
+struct DummyNode final : public nest::stmt::Node
+{
+ // Dummy Node for testing
+};
+}
+
+TEST(BLOCK, use_case_1)
+{
+ nest::Block block;
+
+ ASSERT_EQ(block.size(), 0);
+
+ auto stmt = std::make_shared<DummyNode>();
+
+ block.append(stmt);
+
+ ASSERT_EQ(block.size(), 1);
+ ASSERT_EQ(block.at(0), stmt);
+}