From d4f1efdfda45daee8133f13f2f9e82a0e8593170 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 24 Aug 2018 16:54:13 +0900 Subject: [PATCH] [enco] Introduce MemoryContext class (#1180) This commit introduces MemoryContext class which manages expressions that denote the base address and size of memory region dedicated to each Bag. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/CppGen/MemoryContext.cpp | 9 +++++++ contrib/enco/core/src/CppGen/MemoryContext.h | 33 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 contrib/enco/core/src/CppGen/MemoryContext.cpp create mode 100644 contrib/enco/core/src/CppGen/MemoryContext.h diff --git a/contrib/enco/core/src/CppGen/MemoryContext.cpp b/contrib/enco/core/src/CppGen/MemoryContext.cpp new file mode 100644 index 0000000..ec0f94c --- /dev/null +++ b/contrib/enco/core/src/CppGen/MemoryContext.cpp @@ -0,0 +1,9 @@ +#include "MemoryContext.h" + +namespace enco +{ + +void MemoryContext::base(const coco::Bag *bag, const std::string &exp) { _base[bag] = exp; } +void MemoryContext::size(const coco::Bag *bag, const std::string &exp) { _size[bag] = exp; } + +} // namespace enco diff --git a/contrib/enco/core/src/CppGen/MemoryContext.h b/contrib/enco/core/src/CppGen/MemoryContext.h new file mode 100644 index 0000000..5b28b03 --- /dev/null +++ b/contrib/enco/core/src/CppGen/MemoryContext.h @@ -0,0 +1,33 @@ +#ifndef __ENCO_CPP_GEN_MEMORY_CONTEXT_H__ +#define __ENCO_CPP_GEN_MEMORY_CONTEXT_H__ + +#include + +#include +#include + +namespace enco +{ + +/** + * @brief Record C/C++ expression that denotes the base and size of memory region + * dedicated to each bag + */ +class MemoryContext +{ +public: + void base(const coco::Bag *bag, const std::string &exp); + void size(const coco::Bag *bag, const std::string &exp); + +public: + const std::string &base(const coco::Bag *bag) const { return _base.at(bag); } + const std::string &size(const coco::Bag *bag) const { return _size.at(bag); } + +private: + std::map _base; + std::map _size; +}; + +} // namespace enco + +#endif // __ENCO_CPP_GEN_MEMORY_CONTEXT_H__ -- 2.7.4