diff --git a/CMakeLists.txt b/CMakeLists.txt index 182307f..d184fa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,10 +34,16 @@ include_directories(parser) file(GLOB_RECURSE AST_FILES "parser/*.cpp" "parser/*.h") file(GLOB_RECURSE SOURCE_FILES "src/*.cpp" "src/*.h") +file(GLOB_RECURSE MODULE_FILES "src/*.ixx") + +add_library(Riddle_Module ${SOURCE_FILES}) + +target_sources(Riddle_Module PUBLIC FILE_SET CXX_MODULES FILES ${MODULE_FILES}) add_executable(Riddle_Language ${SOURCE_FILES} ${AST_FILES}) target_compile_definitions(Riddle_Language PRIVATE ${PLATFORM_DEFINES}) target_link_libraries(Riddle_Language LLVMCore) -target_link_libraries(Riddle_Language antlr4_shared) \ No newline at end of file +target_link_libraries(Riddle_Language antlr4_shared) +target_link_libraries(Riddle_Language Riddle_Module) \ No newline at end of file diff --git a/src/Tools/Managers/ClassManager.h b/src/Tools/Managers/ClassManager.h index 68c9331..811c65c 100644 --- a/src/Tools/Managers/ClassManager.h +++ b/src/Tools/Managers/ClassManager.h @@ -6,7 +6,7 @@ #define RIDDLE_LANGUAGE_CLASSMANAGER_H #include -#include "Types/Class.h" +import Types.Class; #include "Types/ClassNode.h" namespace Riddle{ diff --git a/src/Types/Class.cpp b/src/Types/Class.cpp deleted file mode 100644 index 604d5c9..0000000 --- a/src/Types/Class.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// Created by wangz on 24-8-7. -// - -#include "Class.h" - -namespace Riddle{ - -} // Riddle \ No newline at end of file diff --git a/src/Types/Class.h b/src/Types/Class.ixx similarity index 56% rename from src/Types/Class.h rename to src/Types/Class.ixx index 364e990..889150d 100644 --- a/src/Types/Class.h +++ b/src/Types/Class.ixx @@ -1,23 +1,14 @@ -// -// Created by wangz on 24-8-7. -// - -#ifndef CLASS_H -#define CLASS_H - -#include +module; #include #include - -namespace Riddle{ - +#include +export module Types.Class; +export namespace Riddle { class Class { public: llvm::StructType *types = nullptr; - std::unordered_map names; + std::unordered_map names; std::map funcs; }; -} // Riddle - -#endif //CLASS_H +}// namespace Riddle \ No newline at end of file diff --git a/src/Types/ClassNode.h b/src/Types/ClassNode.h index 7951b8a..38644ba 100644 --- a/src/Types/ClassNode.h +++ b/src/Types/ClassNode.h @@ -4,7 +4,7 @@ #ifndef CLASSNODE_H #define CLASSNODE_H -#include "Class.h" +import Types.Class; namespace Riddle{ // 防止内存泄漏,启用 RAII 思想