From b3580e0066e7adb8e9deec83e520f4d918740ff0 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Wed, 16 Oct 2019 00:01:28 +0200
Subject: [PATCH] Begin CMathModule definition

---
 src/language/ASTModulesImporter.cpp |  4 ++++
 src/language/CMakeLists.txt         |  1 +
 src/language/CMathModule.cpp        |  9 +++++++++
 src/language/CMathModule.hpp        | 31 +++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+)
 create mode 100644 src/language/CMathModule.cpp
 create mode 100644 src/language/CMathModule.hpp

diff --git a/src/language/ASTModulesImporter.cpp b/src/language/ASTModulesImporter.cpp
index e15268ec1..257e0d916 100644
--- a/src/language/ASTModulesImporter.cpp
+++ b/src/language/ASTModulesImporter.cpp
@@ -5,6 +5,8 @@
 
 #include <PEGGrammar.hpp>
 
+#include <CMathModule.hpp>
+
 void
 ASTModulesImporter::_importModule(ASTNode& import_node)
 {
@@ -17,6 +19,8 @@ ASTModulesImporter::_importModule(ASTNode& import_node)
   std::cout << " * importing '" << rang::fgB::green << module_name << rang::style::reset << "' module\n";
 
   if (module_name == "math") {
+    CMathModule math_module;
+
     std::string symbol_name{"sin"};
 
     auto [i_symbol, success] = m_symbol_table.add(symbol_name, import_node.begin());
diff --git a/src/language/CMakeLists.txt b/src/language/CMakeLists.txt
index b88c971c4..e00a6a19d 100644
--- a/src/language/CMakeLists.txt
+++ b/src/language/CMakeLists.txt
@@ -28,6 +28,7 @@ add_library(
   ASTPrinter.cpp
   ASTSymbolTableBuilder.cpp
   ASTSymbolInitializationChecker.cpp
+  CMathModule.cpp
   PugsParser.cpp)
 
 # Additional dependencies
diff --git a/src/language/CMathModule.cpp b/src/language/CMathModule.cpp
new file mode 100644
index 000000000..2508026ae
--- /dev/null
+++ b/src/language/CMathModule.cpp
@@ -0,0 +1,9 @@
+#include <CMathModule.hpp>
+
+#include <iostream>
+
+CMathModule::CMathModule()
+{
+  std::cerr << __FILE__ << ':' << __LINE__ << ": CMathModule construction NIY\n";
+  std::exit(1);
+}
diff --git a/src/language/CMathModule.hpp b/src/language/CMathModule.hpp
new file mode 100644
index 000000000..d7d929983
--- /dev/null
+++ b/src/language/CMathModule.hpp
@@ -0,0 +1,31 @@
+#ifndef CMATH_MODULE_HPP
+#define CMATH_MODULE_HPP
+
+#include <PugsMacros.hpp>
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+class ICFunctionEmbedder;
+class CMathModule
+{
+ private:
+  std::map<std::string, uint64_t> m_name_fid_map;
+  std::vector<std::shared_ptr<ICFunctionEmbedder>> m_cfunction_list;
+
+ public:
+  PUGS_INLINE
+  auto
+  find(const std::string& name) const
+  {
+    return m_name_fid_map.find(name);
+  }
+
+  CMathModule();
+
+  ~CMathModule() = default;
+};
+
+#endif   // CMATH_MODULE_HPP
-- 
GitLab