Browse Source

refactor & feat: 提取Code库

SongZihuan 3 years ago
parent
commit
6f2c575c57

+ 1 - 1
CMakeLists.txt

@@ -89,7 +89,7 @@ endif()
 
 
 #include(${CMAKE_CURRENT_LIST_DIR}/lang/hgt.cmake)  # 安装lang库
 #include(${CMAKE_CURRENT_LIST_DIR}/lang/hgt.cmake)  # 安装lang库
 add_subdirectory(src)
 add_subdirectory(src)
-include(aFunHeader)
+include(export-head)
 
 
 #install(EXPORT aFunlang
 #install(EXPORT aFunlang
 #        NAMESPACE "aFunlang::"
 #        NAMESPACE "aFunlang::"

+ 12 - 6
cmake/aFunHeader.cmake → cmake/export-head.cmake

@@ -5,11 +5,15 @@ generate_export_header(tool-shared
                        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunToolExport.h"  # 导出的位置
                        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunToolExport.h"  # 导出的位置
                        BASE_NAME "AFUN_TOOL")
                        BASE_NAME "AFUN_TOOL")
 
 
+generate_export_header(code-shared
+        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunCodeExport.h"  # 导出的位置
+        BASE_NAME "AFUN_CODE")
+
 generate_export_header(core-shared
 generate_export_header(core-shared
                        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunCoreExport.h"  # 导出的位置
                        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunCoreExport.h"  # 导出的位置
                        BASE_NAME "AFUN_CORE")
                        BASE_NAME "AFUN_CORE")
 
 
-generate_export_header(rt-shared
+generate_export_header(it-shared
                        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunlangExport.h"  # 导出的位置
                        EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunlangExport.h"  # 导出的位置
                        BASE_NAME "AFUN_LANG")
                        BASE_NAME "AFUN_LANG")
 
 
@@ -17,16 +21,18 @@ target_compile_definitions(tool-static PUBLIC AFUN_TOOL_STATIC_DEFINE)  # 静态
 target_compile_definitions(tool-static-c PUBLIC AFUN_TOOL_STATIC_DEFINE)
 target_compile_definitions(tool-static-c PUBLIC AFUN_TOOL_STATIC_DEFINE)
 target_compile_definitions(tool-shared-c PRIVATE tool_shared_EXPORTS)
 target_compile_definitions(tool-shared-c PRIVATE tool_shared_EXPORTS)
 
 
+target_compile_definitions(code-static PUBLIC AFUN_CODE_STATIC_DEFINE)
+
 target_compile_definitions(core-static PUBLIC AFUN_CORE_STATIC_DEFINE)
 target_compile_definitions(core-static PUBLIC AFUN_CORE_STATIC_DEFINE)
 
 
-target_compile_definitions(rt-static PUBLIC AFUN_LANG_STATIC_DEFINE)
+target_compile_definitions(it-static PUBLIC AFUN_LANG_STATIC_DEFINE)
 
 
-set_property(TARGET tool-shared tool-shared-c core-shared rt-shared
+set_property(TARGET tool-shared tool-shared-c core-shared it-shared
              PROPERTY C_VISIBILITY_PRESET "hidden")
              PROPERTY C_VISIBILITY_PRESET "hidden")
-set_property(TARGET tool-shared tool-shared-c core-shared rt-shared
+set_property(TARGET tool-shared tool-shared-c core-shared it-shared
              PROPERTY VISIBILITY_INLINES_HIDDEN TRUE)
              PROPERTY VISIBILITY_INLINES_HIDDEN TRUE)
 
 
-set_property(TARGET tool-static tool-static-c core-static rt-static
+set_property(TARGET tool-static tool-static-c core-static it-static
              PROPERTY C_VISIBILITY_PRESET "default")
              PROPERTY C_VISIBILITY_PRESET "default")
-set_property(TARGET tool-static tool-static-c core-static rt-static
+set_property(TARGET tool-static tool-static-c core-static it-static
              PROPERTY VISIBILITY_INLINES_HIDDEN FALSE)
              PROPERTY VISIBILITY_INLINES_HIDDEN FALSE)

+ 1 - 1
cmake/filename.cmake

@@ -1,4 +1,4 @@
-function(define_FILENAME targetname)
+function(define_filename targetname)
     get_target_property(source_files "${targetname}" SOURCES)
     get_target_property(source_files "${targetname}" SOURCES)
     foreach(sourcefile ${source_files})
     foreach(sourcefile ${source_files})
         get_filename_component(basename "${sourcefile}" NAME)
         get_filename_component(basename "${sourcefile}" NAME)

+ 7 - 0
include/code/aFuncode.h

@@ -0,0 +1,7 @@
+#ifndef AFUN_AFUNCODE_H
+#define AFUN_AFUNCODE_H
+
+#include "code.h"
+#include "code-logger.h"
+
+#endif //AFUN_AFUNCODE_H

+ 13 - 0
include/code/code-logger.h

@@ -0,0 +1,13 @@
+#ifndef AFUN_CODE_LOGGER_H
+#define AFUN_CODE_LOGGER_H
+#include "aFunCodeExport.h"
+#include "aFuntool.h"
+
+namespace aFuncode {
+    AFUN_CODE_EXPORT extern aFuntool::Logger *aFunCodeLogger;
+    AFUN_INLINE void setCodeLogger(aFuntool::Logger *log);
+}
+
+#include "code-logger.inline.h"
+
+#endif //AFUN_CODE_LOGGER_H

+ 12 - 0
include/code/code-logger.inline.h

@@ -0,0 +1,12 @@
+#ifndef AFUN_CODE_LOGGER_INLINE_H
+#define AFUN_CODE_LOGGER_INLINE_H
+#include "code-logger.h"
+
+namespace aFuncode {
+    void setCodeLogger(aFuntool::Logger *log) {
+        aFunCodeLogger = log;
+    }
+}
+
+
+#endif //AFUN_CODE_LOGGER_INLINE_H

+ 4 - 4
include/core/code.h → include/code/code.h

@@ -1,10 +1,10 @@
 #ifndef AFUN_CODE_H
 #ifndef AFUN_CODE_H
 #define AFUN_CODE_H
 #define AFUN_CODE_H
 #include "aFuntool.h"
 #include "aFuntool.h"
-#include "aFunCoreExport.h"
+#include "aFunCodeExport.h"
 
 
-namespace aFuncore {
-    class AFUN_CORE_EXPORT Code {
+namespace aFuncode {
+    class AFUN_CODE_EXPORT Code {
     public:
     public:
         class ByteCode;
         class ByteCode;
 
 
@@ -30,7 +30,7 @@ namespace aFuncore {
         bool read_v1(FILE *f, bool debug=false);
         bool read_v1(FILE *f, bool debug=false);
     };
     };
     
     
-    class AFUN_CORE_EXPORT Code::ByteCode {
+    class AFUN_CODE_EXPORT Code::ByteCode {
         friend class Code;
         friend class Code;
     public:
     public:
         typedef enum CodeType {
         typedef enum CodeType {

+ 1 - 1
include/core/code.inline.h → include/code/code.inline.h

@@ -2,7 +2,7 @@
 #define AFUN_CODE_INLINE_H
 #define AFUN_CODE_INLINE_H
 #include "code.h"
 #include "code.h"
 
 
-namespace aFuncore {
+namespace aFuncode {
     Code::Code(aFuntool::FilePath file_) : code{new ByteCode(*this, 0)}, file{std::move(file_)} {
     Code::Code(aFuntool::FilePath file_) : code{new ByteCode(*this, 0)}, file{std::move(file_)} {
 
 
     }
     }

+ 1 - 1
include/core/aFuncore.h

@@ -2,7 +2,7 @@
 #define AFUN_AFUNCORE_H
 #define AFUN_AFUNCORE_H
 
 
 #include "core-init.h"
 #include "core-init.h"
-#include "code.h"
+#include "core-logger.h"
 #include "msg.h"
 #include "msg.h"
 #include "env-var.h"
 #include "env-var.h"
 #include "inter.h"
 #include "inter.h"

+ 19 - 19
include/core/core-activation.h

@@ -3,7 +3,7 @@
 #include "aFuntool.h"
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
 #include "aFunCoreExport.h"
 #include "msg.h"
 #include "msg.h"
-#include "code.h"
+#include "aFuncode.h"
 #include "object-value.h"
 #include "object-value.h"
 
 
 namespace aFuncore {
 namespace aFuncore {
@@ -51,8 +51,8 @@ namespace aFuncore {
         virtual ~Activation();
         virtual ~Activation();
         Activation &operator=(const Activation &)=delete;
         Activation &operator=(const Activation &)=delete;
 
 
-        virtual ActivationStatus getCode(const Code::ByteCode *&code) = 0;
-        virtual void runCode(const Code::ByteCode *code);
+        virtual ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) = 0;
+        virtual void runCode(const aFuncode::Code::ByteCode *code);
         virtual void endRun();
         virtual void endRun();
 
 
         [[nodiscard]] AFUN_INLINE VarList &getVarlist();
         [[nodiscard]] AFUN_INLINE VarList &getVarlist();
@@ -71,41 +71,41 @@ namespace aFuncore {
         aFuntool::FilePath path;
         aFuntool::FilePath path;
         aFuntool::FileLine line;
         aFuntool::FileLine line;
 
 
-        virtual void runCodeElement(const Code::ByteCode *code);
-        virtual void runCodeBlockP(const Code::ByteCode *code);
-        virtual void runCodeBlockC(const Code::ByteCode *code);
-        virtual void runCodeBlockB(const Code::ByteCode *code);
+        virtual void runCodeElement(const aFuncode::Code::ByteCode *code);
+        virtual void runCodeBlockP(const aFuncode::Code::ByteCode *code);
+        virtual void runCodeBlockC(const aFuncode::Code::ByteCode *code);
+        virtual void runCodeBlockB(const aFuncode::Code::ByteCode *code);
     };
     };
 
 
     class AFUN_CORE_EXPORT ExeActivation : public Activation {
     class AFUN_CORE_EXPORT ExeActivation : public Activation {
     public:
     public:
-        AFUN_INLINE ExeActivation(const Code &code, Inter &inter_);
-        AFUN_INLINE ExeActivation(const Code::ByteCode *code, Inter &inter_);
-        ActivationStatus getCode(const Code::ByteCode *&code) override;
-        [[nodiscard]] AFUN_INLINE const Code::ByteCode *getStart() const;
+        AFUN_INLINE ExeActivation(const aFuncode::Code &code, Inter &inter_);
+        AFUN_INLINE ExeActivation(const aFuncode::Code::ByteCode *code, Inter &inter_);
+        ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) override;
+        [[nodiscard]] AFUN_INLINE const aFuncode::Code::ByteCode *getStart() const;
 
 
     private:
     private:
-        const Code::ByteCode *start;
-        const Code::ByteCode *next;
+        const aFuncode::Code::ByteCode *start;
+        const aFuncode::Code::ByteCode *next;
         bool first=true;
         bool first=true;
     };
     };
 
 
     class AFUN_CORE_EXPORT TopActivation : public ExeActivation {
     class AFUN_CORE_EXPORT TopActivation : public ExeActivation {
     public:
     public:
-        explicit TopActivation(const Code &code, Inter &inter_);
+        explicit TopActivation(const aFuncode::Code &code, Inter &inter_);
         ~TopActivation() override = default;
         ~TopActivation() override = default;
-        [[nodiscard]] AFUN_INLINE const Code &getBase() const;
+        [[nodiscard]] AFUN_INLINE const aFuncode::Code &getBase() const;
 
 
     private:
     private:
-        const Code &base;
+        const aFuncode::Code &base;
     };
     };
 
 
     class AFUN_CORE_EXPORT FuncActivation : public Activation {
     class AFUN_CORE_EXPORT FuncActivation : public Activation {
     public:
     public:
-        AFUN_INLINE explicit FuncActivation(const Code::ByteCode *code, Inter &inter_);
+        AFUN_INLINE explicit FuncActivation(const aFuncode::Code::ByteCode *code, Inter &inter_);
         explicit FuncActivation(Function *func, Inter &inter_);
         explicit FuncActivation(Function *func, Inter &inter_);
         ~FuncActivation() override;
         ~FuncActivation() override;
-        ActivationStatus getCode(const Code::ByteCode *&code) override;
+        ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) override;
         void endRun() override;
         void endRun() override;
 
 
     private:
     private:
@@ -116,7 +116,7 @@ namespace aFuncore {
         } status = func_first;
         } status = func_first;
 
 
         bool on_tail = false;
         bool on_tail = false;
-        const Code::ByteCode *call;
+        const aFuncode::Code::ByteCode *call;
 
 
         Function *func = nullptr;
         Function *func = nullptr;
         Function::CallFunction *call_func = nullptr;
         Function::CallFunction *call_func = nullptr;

+ 5 - 5
include/core/core-activation.inline.h

@@ -52,23 +52,23 @@ namespace aFuncore {
         return var ? var->getData() : nullptr;
         return var ? var->getData() : nullptr;
     }
     }
 
 
-    ExeActivation::ExeActivation(const Code &code, Inter &inter_) : Activation(inter_), start{code.getByteCode()}, next{code.getByteCode()} {
+    ExeActivation::ExeActivation(const aFuncode::Code &code, Inter &inter_) : Activation(inter_), start{code.getByteCode()}, next{code.getByteCode()} {
 
 
     }
     }
 
 
-    ExeActivation::ExeActivation(const Code::ByteCode *code, Inter &inter_) : Activation(inter_), start{code}, next{code} {
+    ExeActivation::ExeActivation(const aFuncode::Code::ByteCode *code, Inter &inter_) : Activation(inter_), start{code}, next{code} {
 
 
     }
     }
 
 
-    const Code::ByteCode *ExeActivation::getStart() const{
+    const aFuncode::Code::ByteCode *ExeActivation::getStart() const{
         return start;
         return start;
     }
     }
 
 
-    const Code &TopActivation::getBase() const {
+    const aFuncode::Code &TopActivation::getBase() const {
         return base;
         return base;
     }
     }
 
 
-    FuncActivation::FuncActivation(const Code::ByteCode *code, Inter &inter_) : Activation(inter_), call{code} {
+    FuncActivation::FuncActivation(const aFuncode::Code::ByteCode *code, Inter &inter_) : Activation(inter_), call{code} {
 
 
     }
     }
 }
 }

+ 10 - 0
include/core/core-logger.h

@@ -0,0 +1,10 @@
+#ifndef AFUN_CORE_LOGGER_H
+#define AFUN_CORE_LOGGER_H
+#include "aFuntool.h"
+#include "aFunCoreExport.h"
+
+namespace aFuncore {
+    AFUN_CORE_EXPORT extern aFuntool::Logger *aFunCoreLogger;
+}
+
+#endif //AFUN_CORE_LOGGER_H

+ 6 - 6
include/core/core-parser.h

@@ -2,7 +2,7 @@
 #define AFUN_CORE_PARSER_H
 #define AFUN_CORE_PARSER_H
 #include "aFunToolExport.h"
 #include "aFunToolExport.h"
 #include "reader.h"
 #include "reader.h"
-#include "code.h"
+#include "aFuncode.h"
 #include <queue>
 #include <queue>
 
 
 namespace aFuncore {
 namespace aFuncore {
@@ -74,7 +74,7 @@ namespace aFuncore {
         AFUN_INLINE explicit Parser(Reader &reader_);
         AFUN_INLINE explicit Parser(Reader &reader_);
 
 
         TokenType getTokenFromLexical(std::string &text);
         TokenType getTokenFromLexical(std::string &text);
-        bool parserCode(Code &code);
+        bool parserCode(aFuncode::Code &code);
 
 
         [[nodiscard]] AFUN_INLINE size_t countEvent() const;
         [[nodiscard]] AFUN_INLINE size_t countEvent() const;
         AFUN_INLINE ParserEvent popEvent();
         AFUN_INLINE ParserEvent popEvent();
@@ -120,10 +120,10 @@ namespace aFuncore {
         bool goBackToken();
         bool goBackToken();
 
 
         AFUN_STATIC const size_t SYNTACTIC_MAX_DEPTH = 218;
         AFUN_STATIC const size_t SYNTACTIC_MAX_DEPTH = 218;
-        Code::ByteCode *codeSelf(Code &code, size_t deep, char prefix);
-        Code::ByteCode *codePrefix(Code &code, size_t deep);
-        Code::ByteCode *codeList(Code &code, size_t deep);
-        Code::ByteCode *codeListEnd(Code &code);
+        aFuncode::Code::ByteCode *codeSelf(aFuncode::Code &code, size_t deep, char prefix);
+        aFuncode::Code::ByteCode *codePrefix(aFuncode::Code &code, size_t deep);
+        aFuncode::Code::ByteCode *codeList(aFuncode::Code &code, size_t deep);
+        aFuncode::Code::ByteCode *codeListEnd(aFuncode::Code &code);
 
 
         AFUN_INLINE void pushEvent(const ParserEvent &new_event);
         AFUN_INLINE void pushEvent(const ParserEvent &new_event);
         AFUN_INLINE void pushEvent(ParserEvent &&new_event);
         AFUN_INLINE void pushEvent(ParserEvent &&new_event);

+ 2 - 2
include/core/inter.h

@@ -5,7 +5,7 @@
 #include "aFuntool.h"
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
 #include "aFunCoreExport.h"
 
 
-#include "code.h"
+#include "aFuncode.h"
 #include "env-var.h"
 #include "env-var.h"
 #include "msg.h"
 #include "msg.h"
 
 
@@ -92,7 +92,7 @@ namespace aFuncore {
         bool pushLiteral(const std::string &pattern, const std::string &literaler, bool in_protect);
         bool pushLiteral(const std::string &pattern, const std::string &literaler, bool in_protect);
 
 
         bool runCode();
         bool runCode();
-        bool runCode(const Code &code);
+        bool runCode(const aFuncode::Code &code);
         bool runCode(Object *obj);
         bool runCode(Object *obj);
 
 
         AFUN_INLINE InterStatus setInterStop();
         AFUN_INLINE InterStatus setInterStop();

+ 5 - 5
include/core/object-value.h

@@ -5,7 +5,7 @@
 #include "aFuntool.h"
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
 #include "aFunCoreExport.h"
 #include "object.h"
 #include "object.h"
-#include "code.h"
+#include "aFuncode.h"
 #include "inter.h"
 #include "inter.h"
 
 
 namespace aFuncore {
 namespace aFuncore {
@@ -83,7 +83,7 @@ namespace aFuncore {
     public:
     public:
         class AFUN_CORE_EXPORT CallFunction;
         class AFUN_CORE_EXPORT CallFunction;
 
 
-        virtual CallFunction *getCallFunction(const Code::ByteCode *code, Inter &inter) = 0;
+        virtual CallFunction *getCallFunction(const aFuncode::Code::ByteCode *code, Inter &inter) = 0;
         virtual bool isInfix();
         virtual bool isInfix();
     };
     };
 
 
@@ -96,14 +96,14 @@ namespace aFuncore {
         CallFunction(const CallFunction &)=delete;
         CallFunction(const CallFunction &)=delete;
         CallFunction &operator=(const CallFunction &)=delete;
         CallFunction &operator=(const CallFunction &)=delete;
 
 
-        virtual std::list<ArgCodeList> *getArgCodeList(Inter &inter, Activation &activation, const Code::ByteCode *call) = 0;
+        virtual std::list<ArgCodeList> *getArgCodeList(Inter &inter, Activation &activation, const aFuncode::Code::ByteCode *call) = 0;
         virtual void runFunction() = 0;
         virtual void runFunction() = 0;
     };
     };
 
 
     class Function::CallFunction::ArgCodeList {
     class Function::CallFunction::ArgCodeList {
     public:
     public:
-        const Code::ByteCode *code = nullptr;
-        AFUN_INLINE explicit ArgCodeList(const Code::ByteCode *code = nullptr);
+        const aFuncode::Code::ByteCode *code = nullptr;
+        AFUN_INLINE explicit ArgCodeList(const aFuncode::Code::ByteCode *code = nullptr);
         AFUN_INLINE ~ArgCodeList();
         AFUN_INLINE ~ArgCodeList();
         AFUN_INLINE Object *setObject(Object *res);
         AFUN_INLINE Object *setObject(Object *res);
         AFUN_INLINE Object *getObject();
         AFUN_INLINE Object *getObject();

+ 1 - 1
include/core/object-value.inline.h

@@ -29,7 +29,7 @@ namespace aFuncore {
         bool ret = is_protect; is_protect = protect; return ret;
         bool ret = is_protect; is_protect = protect; return ret;
     }
     }
 
 
-    Function::CallFunction::ArgCodeList::ArgCodeList(const Code::ByteCode *code_) : code{code_}, ret{nullptr} {
+    Function::CallFunction::ArgCodeList::ArgCodeList(const aFuncode::Code::ByteCode *code_) : code{code_}, ret{nullptr} {
 
 
     }
     }
 
 

+ 16 - 17
src/CMakeLists.txt

@@ -1,29 +1,28 @@
 set(build_include_tool ${PROJECT_SOURCE_DIR}/include/tool)
 set(build_include_tool ${PROJECT_SOURCE_DIR}/include/tool)
-set(install_include_tool ${INSTALL_INCLUDEDIR})
-
+set(build_include_code ${PROJECT_SOURCE_DIR}/include/code)
 set(build_include_core ${PROJECT_SOURCE_DIR}/include/core)
 set(build_include_core ${PROJECT_SOURCE_DIR}/include/core)
-set(install_include_core ${INSTALL_INCLUDEDIR})
-
 set(build_include_interface ${PROJECT_SOURCE_DIR}/include/interface)
 set(build_include_interface ${PROJECT_SOURCE_DIR}/include/interface)
-set(install_include_interface ${INSTALL_INCLUDEDIR})
 
 
-set(build_include_
-    ${hgt_dir}
-    ${base_include_dir}
-    ${build_include_tool}
-    ${build_include_core}
-    ${build_include_core_info}
-    ${build_include_interface})
+set(install_include_tool ${INSTALL_INCLUDEDIR})
+set(install_include_code ${INSTALL_INCLUDEDIR})
+set(install_include_core ${INSTALL_INCLUDEDIR})
+set(install_include_interface ${INSTALL_INCLUDEDIR})
 
 
 set(build_include)
 set(build_include)
-foreach(dir IN LISTS build_include_)
+foreach(dir
+        ${hgt_dir}
+        ${base_include_dir}
+        ${build_include_tool}
+        ${build_include_code}
+        ${build_include_core}
+        ${build_include_interface})
     list(APPEND build_include $<BUILD_INTERFACE:${dir}>)
     list(APPEND build_include $<BUILD_INTERFACE:${dir}>)
 endforeach()
 endforeach()
-unset(build_include_)
 
 
 set(install_include $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>)
 set(install_include $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>)
 
 
 add_subdirectory(tool)
 add_subdirectory(tool)
+add_subdirectory(code)
 add_subdirectory(core)  # core 依赖 tool
 add_subdirectory(core)  # core 依赖 tool
 add_subdirectory(interface)  # interface 依赖 core
 add_subdirectory(interface)  # interface 依赖 core
 
 
@@ -50,11 +49,11 @@ add_subdirectory(interface)  # interface 依赖 core
 #                AFUN_MAJOR_VERSION=${PROJECT_VERSION_MAJOR}
 #                AFUN_MAJOR_VERSION=${PROJECT_VERSION_MAJOR}
 #                AFUN_MINOR_VERSION=${PROJECT_VERSION_MINOR}
 #                AFUN_MINOR_VERSION=${PROJECT_VERSION_MINOR}
 #                AFUN_PATCH_VERSION=${PROJECT_VERSION_PATCH})
 #                AFUN_PATCH_VERSION=${PROJECT_VERSION_PATCH})
-#    define_FILENAME(${tgt})
+#    define_filename(${tgt})
 #endforeach()
 #endforeach()
 #
 #
-#target_link_libraries(aFun-xx PUBLIC rt-shared FFlags::fflags)
-#target_link_libraries(aFun-ct PUBLIC rt-static FFlags::fflags)
+#target_link_libraries(aFun-xx PUBLIC it-shared FFlags::fflags)
+#target_link_libraries(aFun-ct PUBLIC it-static FFlags::fflags)
 #
 #
 #install(TARGETS aFun-xx aFun-ct
 #install(TARGETS aFun-xx aFun-ct
 #        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT dev
 #        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT dev

+ 41 - 0
src/code/CMakeLists.txt

@@ -0,0 +1,41 @@
+file(GLOB source
+        LIST_DIRECTORIES FALSE
+        ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
+
+file(GLOB public_h
+        LIST_DIRECTORIES FALSE
+        RELATIVE "${build_include_code}"
+        "${build_include_code}/*.h")
+
+set(public_h_build)
+set(public_h_install)
+
+foreach(h IN LISTS public_h)
+    file(RELATIVE_PATH _path ${CMAKE_CURRENT_LIST_DIR} "${build_include_code}/${h}")
+    list(APPEND public_h_build   "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${_path}>")  # 相对路径的转换, 此处只能使用相对路径
+    list(APPEND public_h_install "$<INSTALL_INTERFACE:${install_include_code}/${h}>")
+endforeach()
+
+add_library(code-shared SHARED "")
+add_library(code-static STATIC "")
+
+foreach(tgt code-shared code-static)
+    target_sources(${tgt} PRIVATE ${source} PUBLIC ${public_h_build} ${public_h_install})
+    target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
+    set_target_properties(${tgt} PROPERTIES
+            PUBLIC_HEADER "${public_h_build}")
+    define_filename(${tgt})
+endforeach()
+
+set_target_properties(code-shared PROPERTIES OUTPUT_NAME "aFuncode")
+set_target_properties(code-static PROPERTIES OUTPUT_NAME "aFuncode-s")
+
+target_link_libraries(code-shared PUBLIC tool-shared)
+target_link_libraries(code-static PUBLIC tool-static)
+#
+#install(TARGETS code-shared code-static
+#        EXPORT aFunlang
+#        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
+#        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
+#        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
+#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev)

+ 5 - 0
src/code/code-logger.cpp

@@ -0,0 +1,5 @@
+#include "code-logger.h"
+
+namespace aFuncode {
+    aFuntool::Logger *aFunCodeLogger = nullptr;
+}

+ 32 - 32
src/core/code.cpp → src/code/code.cpp

@@ -1,7 +1,7 @@
 #include "code.h"
 #include "code.h"
-#include "core-init.h"
+#include "code-logger.h"
 
 
-namespace aFuncore {
+namespace aFuncode {
     Code::~Code(){
     Code::~Code(){
         ByteCode *next_tmp;
         ByteCode *next_tmp;
         while (code != nullptr) {
         while (code != nullptr) {
@@ -29,7 +29,7 @@ namespace aFuncore {
      */
      */
     void Code::display() const{
     void Code::display() const{
         if (code->type != ByteCode::code_start) {
         if (code->type != ByteCode::code_start) {
-            errorLog(aFunCoreLogger, "Code display all did not with `start`");
+            errorLog(aFunCodeLogger, "Code display all did not with `start`");
             return;
             return;
         }
         }
 
 
@@ -56,7 +56,7 @@ namespace aFuncore {
 
 
 #define done(write) do{ \
 #define done(write) do{ \
 if(!(write)){ \
 if(!(write)){ \
-    errorLog(aFunCoreLogger, "Write/Read bytecode fail: %s [%p]", #write, f); \
+    errorLog(aFunCodeLogger, "Write/Read bytecode fail: %s [%p]", #write, f); \
     return false; \
     return false; \
 }} while(0)
 }} while(0)
     /**
     /**
@@ -68,10 +68,10 @@ if(!(write)){ \
      */
      */
     bool Code::write_v1(FILE *f, bool debug) const{
     bool Code::write_v1(FILE *f, bool debug) const{
         if (code->type != ByteCode::code_start) {
         if (code->type != ByteCode::code_start) {
-            errorLog(aFunCoreLogger, "Code write all did not with `start`");
+            errorLog(aFunCodeLogger, "Code write all did not with `start`");
             return false;
             return false;
         } else
         } else
-            debugLog(aFunCoreLogger, "Write Bytecode to %p (debug: %d)", f, debug);
+            debugLog(aFunCodeLogger, "Write Bytecode to %p (debug: %d)", f, debug);
 
 
         const Code::ByteCode *tmp = code;
         const Code::ByteCode *tmp = code;
         while (tmp != nullptr) {
         while (tmp != nullptr) {
@@ -104,10 +104,10 @@ if(!(write)){ \
      */
      */
     bool Code::read_v1(FILE *f, bool debug) {
     bool Code::read_v1(FILE *f, bool debug) {
         if (code->type != ByteCode::code_start) {
         if (code->type != ByteCode::code_start) {
-            errorLog(aFunCoreLogger, "Code read all did not with `start`");
+            errorLog(aFunCodeLogger, "Code read all did not with `start`");
             return false;
             return false;
         } else
         } else
-            debugLog(aFunCoreLogger, "Read Bytecode from %p (debug: %d)", f, debug);
+            debugLog(aFunCodeLogger, "Read Bytecode from %p (debug: %d)", f, debug);
 
 
         Code::ByteCode *father_ = nullptr;
         Code::ByteCode *father_ = nullptr;
         Code::ByteCode *next_ = code;
         Code::ByteCode *next_ = code;
@@ -120,7 +120,7 @@ if(!(write)){ \
                     goto RETURN;
                     goto RETURN;
                 case 3:
                 case 3:
                     if (next_ == nullptr) {
                     if (next_ == nullptr) {
-                        errorLog(aFunCoreLogger, "Code without father");
+                        errorLog(aFunCodeLogger, "Code without father");
                         return false;
                         return false;
                     }
                     }
                     next_ = next_->father;
                     next_ = next_->father;
@@ -132,12 +132,12 @@ if(!(write)){ \
                     else if (next_ != nullptr)
                     else if (next_ != nullptr)
                         ret = next_->read_v1(f, debug, type_, false);
                         ret = next_->read_v1(f, debug, type_, false);
                     else {
                     else {
-                        errorLog(aFunCoreLogger, "Code read with unknown error");
+                        errorLog(aFunCodeLogger, "Code read with unknown error");
                         return false;
                         return false;
                     }
                     }
 
 
                     if (ret == nullptr) {
                     if (ret == nullptr) {
-                        errorLog(aFunCoreLogger, "Code read fail");
+                        errorLog(aFunCodeLogger, "Code read fail");
                         return false;
                         return false;
                     } else if (type_ == ByteCode::code_block) {
                     } else if (type_ == ByteCode::code_block) {
                         next_ = nullptr;
                         next_ = nullptr;
@@ -162,7 +162,7 @@ RETURN:
      */
      */
     std::string Code::getMD5_v1() const{
     std::string Code::getMD5_v1() const{
         if (code->type != ByteCode::code_start) {
         if (code->type != ByteCode::code_start) {
-            errorLog(aFunCoreLogger, "Code get md5 all did not with `start`");
+            errorLog(aFunCodeLogger, "Code get md5 all did not with `start`");
             return "";
             return "";
         }
         }
 
 
@@ -202,7 +202,7 @@ RETURN:
 
 
 #define done(write) do{ \
 #define done(write) do{ \
 if(!(write)){           \
 if(!(write)){           \
-    errorLog(aFunCoreLogger, "Write/Read bytecode file fail: %s [%p]", #write, f); \
+    errorLog(aFunCodeLogger, "Write/Read bytecode file fail: %s [%p]", #write, f); \
     goto RETURN_FALSE; \
     goto RETURN_FALSE; \
 }}while(0)
 }}while(0)
 
 
@@ -214,16 +214,16 @@ if(!(write)){           \
      */
      */
     bool Code::writeByteCode(const aFuntool::FilePath &file_path, bool debug) const{
     bool Code::writeByteCode(const aFuntool::FilePath &file_path, bool debug) const{
         if (code->type != ByteCode::code_start) {
         if (code->type != ByteCode::code_start) {
-            errorLog(aFunCoreLogger, "ByteCode write all did not with `start`");
+            errorLog(aFunCodeLogger, "ByteCode write all did not with `start`");
             return false;
             return false;
         }
         }
 
 
         FILE *f = aFuntool::fileOpen(file_path, "wb");
         FILE *f = aFuntool::fileOpen(file_path, "wb");
         if (f == nullptr) {
         if (f == nullptr) {
-            errorLog(aFunCoreLogger, "Write ByteCode file create file fail.");
+            errorLog(aFunCodeLogger, "Write ByteCode file create file fail.");
             return false;
             return false;
         } else
         } else
-            debugLog(aFunCoreLogger, "Write Bytecode file %s [%p] (debug: %d)", file_path.c_str(), f, debug);
+            debugLog(aFunCodeLogger, "Write Bytecode file %s [%p] (debug: %d)", file_path.c_str(), f, debug);
 
 
         done(aFuntool::byteWriteStr(f, ByteCodeHead));
         done(aFuntool::byteWriteStr(f, ByteCodeHead));
         done(aFuntool::byteWriteInt(f, int16_t(MaxByteCodeVersion)));
         done(aFuntool::byteWriteInt(f, int16_t(MaxByteCodeVersion)));
@@ -231,12 +231,12 @@ if(!(write)){           \
         done(aFuntool::byteWriteInt(f, int8_t(debug)));
         done(aFuntool::byteWriteInt(f, int8_t(debug)));
         done(write_v1(f, debug));
         done(write_v1(f, debug));
         aFuntool::fileClose(f);
         aFuntool::fileClose(f);
-        debugLog(aFunCoreLogger, "Write Bytecode file success");
+        debugLog(aFunCodeLogger, "Write Bytecode file success");
         return true;
         return true;
 
 
 RETURN_FALSE:
 RETURN_FALSE:
         aFuntool::fileClose(f);
         aFuntool::fileClose(f);
-        debugLog(aFunCoreLogger, "Write Bytecode file fail");
+        debugLog(aFunCodeLogger, "Write Bytecode file fail");
         return false;
         return false;
     }
     }
 
 
@@ -247,16 +247,16 @@ RETURN_FALSE:
      */
      */
     bool Code::readByteCode(const aFuntool::FilePath &file_path){
     bool Code::readByteCode(const aFuntool::FilePath &file_path){
         if (code->type != ByteCode::code_start) {
         if (code->type != ByteCode::code_start) {
-            errorLog(aFunCoreLogger, "ByteCode read all did not with `start`");
+            errorLog(aFunCodeLogger, "ByteCode read all did not with `start`");
             return false;
             return false;
         }
         }
 
 
         FILE *f = aFuntool::fileOpen(file_path, "rb");
         FILE *f = aFuntool::fileOpen(file_path, "rb");
         if (f == nullptr) {
         if (f == nullptr) {
-            warningLog(aFunCoreLogger, "Read ByteCode read file fail.");
+            warningLog(aFunCodeLogger, "Read ByteCode read file fail.");
             return false;
             return false;
         } else
         } else
-            debugLog(aFunCoreLogger, "Read Bytecode file %s [%p]", file_path.c_str(), f);
+            debugLog(aFunCodeLogger, "Read Bytecode file %s [%p]", file_path.c_str(), f);
 
 
         std::string head;
         std::string head;
         done(aFuntool::byteReadStr(f, head));
         done(aFuntool::byteReadStr(f, head));
@@ -267,7 +267,7 @@ RETURN_FALSE:
         done(aFuntool::byteReadInt(f, &version));
         done(aFuntool::byteReadInt(f, &version));
         switch (version) {  // NOLINT 为拓展方便, 使用switch-case而不是if-else
         switch (version) {  // NOLINT 为拓展方便, 使用switch-case而不是if-else
             case 1: {
             case 1: {
-                debugLog(aFunCoreLogger, "Read Bytecode file version 1");
+                debugLog(aFunCodeLogger, "Read Bytecode file version 1");
                 std::string md5;
                 std::string md5;
                 int8_t debug;
                 int8_t debug;
                 done(aFuntool::byteReadStr(f, md5));
                 done(aFuntool::byteReadStr(f, md5));
@@ -280,16 +280,16 @@ RETURN_FALSE:
                 break;
                 break;
             }
             }
             default:
             default:
-                errorLog(aFunCoreLogger, "Read Bytecode file bad version");
+                errorLog(aFunCodeLogger, "Read Bytecode file bad version");
                 goto RETURN_FALSE;
                 goto RETURN_FALSE;
         }
         }
         aFuntool::fileClose(f);
         aFuntool::fileClose(f);
-        debugLog(aFunCoreLogger, "Read Bytecode file success");
+        debugLog(aFunCodeLogger, "Read Bytecode file success");
         return true;
         return true;
 
 
 RETURN_FALSE:
 RETURN_FALSE:
         aFuntool::fileClose(f);
         aFuntool::fileClose(f);
-        debugLog(aFunCoreLogger, "Read Bytecode file fail");
+        debugLog(aFunCodeLogger, "Read Bytecode file fail");
         return false;
         return false;
     }
     }
 
 
@@ -319,7 +319,7 @@ RETURN_FALSE:
         this->line = line;
         this->line = line;
 
 
         if (!aFuntool::isCharUTF8(element)) {
         if (!aFuntool::isCharUTF8(element)) {
-            errorLog(aFunCoreLogger, "Element not utf-8");
+            errorLog(aFunCodeLogger, "Element not utf-8");
             this->data.element = nullptr;
             this->data.element = nullptr;
         } else
         } else
             this->data.element = aFuntool::strCopy(element.c_str());
             this->data.element = aFuntool::strCopy(element.c_str());
@@ -365,12 +365,12 @@ RETURN_FALSE:
             return tmp;
             return tmp;
 
 
         if (new_code->type == code_start) {
         if (new_code->type == code_start) {
-            errorLog(aFunCoreLogger, "Code connect with `start`");
+            errorLog(aFunCodeLogger, "Code connect with `start`");
             return tmp;
             return tmp;
         }
         }
 
 
         if (&new_code->belong != &tmp->belong) {
         if (&new_code->belong != &tmp->belong) {
-            errorLog(aFunCoreLogger, "Code connect with difference belong");
+            errorLog(aFunCodeLogger, "Code connect with difference belong");
             return tmp;
             return tmp;
         }
         }
 
 
@@ -401,7 +401,7 @@ RETURN_FALSE:
 
 
 #define done(write) do{ \
 #define done(write) do{ \
 if(!(write)){           \
 if(!(write)){           \
-    errorLog(aFunCoreLogger, "Write Code::ByteCode fail: %s [%p]", #write, f); \
+    errorLog(aFunCodeLogger, "Write Code::ByteCode fail: %s [%p]", #write, f); \
     return false; \
     return false; \
 }}while(0)
 }}while(0)
 
 
@@ -438,7 +438,7 @@ if(!(write)){           \
 #undef done
 #undef done
 #define done(write) do{ \
 #define done(write) do{ \
 if(!(write)){           \
 if(!(write)){           \
-    errorLog(aFunCoreLogger, "Read Code::ByteCode fail: %s [%p]", #write, f); \
+    errorLog(aFunCodeLogger, "Read Code::ByteCode fail: %s [%p]", #write, f); \
     return nullptr;         \
     return nullptr;         \
 }}while(0)
 }}while(0)
 
 
@@ -471,7 +471,7 @@ if(!(write)){           \
                 break;
                 break;
             }
             }
             default:
             default:
-                errorLog(aFunCoreLogger, "Read code with bad type.");
+                errorLog(aFunCodeLogger, "Read code with bad type.");
                 return nullptr;
                 return nullptr;
         }
         }
 
 
@@ -483,7 +483,7 @@ if(!(write)){           \
 
 
         if (to_son) {
         if (to_son) {
             if (type != code_block || data.block.son != nullptr) {
             if (type != code_block || data.block.son != nullptr) {
-                errorLog(aFunCoreLogger, "Read son with bad type.");
+                errorLog(aFunCodeLogger, "Read son with bad type.");
                 delete ret;
                 delete ret;
                 return nullptr;
                 return nullptr;
             }
             }

+ 8 - 15
src/core/CMakeLists.txt

@@ -2,10 +2,6 @@
      LIST_DIRECTORIES FALSE
      LIST_DIRECTORIES FALSE
      ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
      ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
 
 
-file(GLOB private_h
-     LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/*.h)
-
 file(GLOB public_h
 file(GLOB public_h
      LIST_DIRECTORIES FALSE
      LIST_DIRECTORIES FALSE
      RELATIVE "${build_include_core}"
      RELATIVE "${build_include_core}"
@@ -20,28 +16,25 @@ foreach(h IN LISTS public_h)
     list(APPEND public_h_install "$<INSTALL_INTERFACE:${install_include_core}/${h}>")
     list(APPEND public_h_install "$<INSTALL_INTERFACE:${install_include_core}/${h}>")
 endforeach()
 endforeach()
 
 
-add_library(core-shared SHARED "")  # core和tool动态库
-add_library(core-static STATIC "")  # core和tool静态库
+add_library(core-shared SHARED "")
+add_library(core-static STATIC "")
 
 
 foreach(tgt core-shared core-static)
 foreach(tgt core-shared core-static)
-    target_sources(${tgt} PRIVATE ${source} ${private_h} PUBLIC ${public_h_build} ${public_h_install})
+    target_sources(${tgt} PRIVATE ${source} PUBLIC ${public_h_build} ${public_h_install})
     target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
     target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
-    set_target_properties(${tgt} PROPERTIES
-                          PUBLIC_HEADER "${public_h_build}"
-                          PRIVATE_HEADER "${private_h}")  # PRIVATE_HEADER私有头文件, 可以用于高级开发
-    define_FILENAME(${tgt})
+    set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}")
+    define_filename(${tgt})
 endforeach()
 endforeach()
 
 
 set_target_properties(core-shared PROPERTIES OUTPUT_NAME "aFuncore")
 set_target_properties(core-shared PROPERTIES OUTPUT_NAME "aFuncore")
 set_target_properties(core-static PROPERTIES OUTPUT_NAME "aFuncore-s")
 set_target_properties(core-static PROPERTIES OUTPUT_NAME "aFuncore-s")
 
 
-target_link_libraries(core-shared PUBLIC tool-shared)
-target_link_libraries(core-static PUBLIC tool-static)
+target_link_libraries(core-shared PUBLIC code-shared)
+target_link_libraries(core-static PUBLIC code-static)
 #
 #
 #install(TARGETS core-shared core-static
 #install(TARGETS core-shared core-static
 #        EXPORT aFunlang
 #        EXPORT aFunlang
 #        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
 #        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
 #        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
 #        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
 #        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
 #        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
-#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev
-#        PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT advanced-dev)
+#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev)

+ 19 - 19
src/core/activation.cpp

@@ -1,8 +1,8 @@
 #include "core-activation.h"
 #include "core-activation.h"
 #include "inter.h"
 #include "inter.h"
-#include "core-init.h"
+#include "core-logger.h"
 #include "msg.h"
 #include "msg.h"
-#include "code.h"
+#include "aFuncode.h"
 #include "core-exception.h"
 #include "core-exception.h"
 
 
 namespace aFuncore {
 namespace aFuncore {
@@ -55,24 +55,24 @@ namespace aFuncore {
      * 运行代码
      * 运行代码
      * @param code
      * @param code
      */
      */
-    void Activation::runCode(const Code::ByteCode *code){
+    void Activation::runCode(const aFuncode::Code::ByteCode *code){
         auto code_type = code->getType();
         auto code_type = code->getType();
-        if (code_type == Code::ByteCode::code_start) {  // start 不处理 msg
+        if (code_type == aFuncode::Code::ByteCode::code_start) {  // start 不处理 msg
             auto *none = new Object("None", inter);
             auto *none = new Object("None", inter);
             down.pushMessage("NORMAL", new NormalMessage(none));
             down.pushMessage("NORMAL", new NormalMessage(none));
             none->delReference();
             none->delReference();
         } else {
         } else {
-            if (code_type == Code::ByteCode::code_element) {
+            if (code_type == aFuncode::Code::ByteCode::code_element) {
                 runCodeElement(code);
                 runCodeElement(code);
             } else
             } else
                 switch (code->getBlockType()) {
                 switch (code->getBlockType()) {
-                    case Code::ByteCode::block_p:  // 顺序执行
+                    case aFuncode::Code::ByteCode::block_p:  // 顺序执行
                         runCodeBlockP(code);
                         runCodeBlockP(code);
                         break;
                         break;
-                    case Code::ByteCode::block_b:
+                    case aFuncode::Code::ByteCode::block_b:
                         runCodeBlockB(code);
                         runCodeBlockB(code);
                         break;
                         break;
-                    case Code::ByteCode::block_c:
+                    case aFuncode::Code::ByteCode::block_c:
                         runCodeBlockC(code);
                         runCodeBlockC(code);
                         break;
                         break;
                     default:
                     default:
@@ -82,7 +82,7 @@ namespace aFuncore {
         }
         }
     }
     }
 
 
-    void Activation::runCodeElement(const Code::ByteCode *code){
+    void Activation::runCodeElement(const aFuncode::Code::ByteCode *code){
         std::string literaler_name;
         std::string literaler_name;
         bool in_protect = false;
         bool in_protect = false;
         Object *obj = nullptr;
         Object *obj = nullptr;
@@ -111,19 +111,19 @@ namespace aFuncore {
         }
         }
     }
     }
 
 
-    void Activation::runCodeBlockP(const Code::ByteCode *code){
+    void Activation::runCodeBlockP(const aFuncode::Code::ByteCode *code){
         new ExeActivation(code->getSon(), inter);
         new ExeActivation(code->getSon(), inter);
     }
     }
 
 
-    void Activation::runCodeBlockC(const Code::ByteCode *code){
+    void Activation::runCodeBlockC(const aFuncode::Code::ByteCode *code){
         new FuncActivation(code, inter);
         new FuncActivation(code, inter);
     }
     }
 
 
-    void Activation::runCodeBlockB(const Code::ByteCode *code){
+    void Activation::runCodeBlockB(const aFuncode::Code::ByteCode *code){
         new FuncActivation(code, inter);
         new FuncActivation(code, inter);
     }
     }
 
 
-    Activation::ActivationStatus ExeActivation::getCode(const Code::ByteCode *&code){
+    Activation::ActivationStatus ExeActivation::getCode(const aFuncode::Code::ByteCode *&code){
         code = next;
         code = next;
         if (code == nullptr)
         if (code == nullptr)
             return as_end;
             return as_end;
@@ -233,7 +233,7 @@ namespace aFuncore {
         }
         }
     }
     }
 
 
-    TopActivation::TopActivation(const Code &code, Inter &inter_) : ExeActivation(code, inter_), base{code} {
+    TopActivation::TopActivation(const aFuncode::Code &code, Inter &inter_) : ExeActivation(code, inter_), base{code} {
 
 
     }
     }
 
 
@@ -248,13 +248,13 @@ namespace aFuncore {
         delete call_func;
         delete call_func;
     }
     }
 
 
-    Activation::ActivationStatus FuncActivation::getCode(const Code::ByteCode *&code) {
+    Activation::ActivationStatus FuncActivation::getCode(const aFuncode::Code::ByteCode *&code) {
         if (on_tail)
         if (on_tail)
             return as_end;
             return as_end;
 
 
         if (status == func_first) {
         if (status == func_first) {
             switch (call->getBlockType()) {
             switch (call->getBlockType()) {
-                case Code::ByteCode::block_c:
+                case aFuncode::Code::ByteCode::block_c:
                     status = func_get_func;
                     status = func_get_func;
                     code = call->getSon();
                     code = call->getSon();
                     if (code == nullptr) {
                     if (code == nullptr) {
@@ -266,14 +266,14 @@ namespace aFuncore {
                     if (!code->getFilePath().empty())
                     if (!code->getFilePath().empty())
                         path = code->getFilePath();
                         path = code->getFilePath();
                     return as_run;
                     return as_run;
-                case Code::ByteCode::block_b: {
+                case aFuncode::Code::ByteCode::block_b: {
                     std::string prefix;
                     std::string prefix;
                     if (!inter.getEnvVarSpace().findString("sys:prefix", prefix) ||
                     if (!inter.getEnvVarSpace().findString("sys:prefix", prefix) ||
                         prefix.size() != Inter::PREFIX_COUNT)
                         prefix.size() != Inter::PREFIX_COUNT)
                         prefix = "''";
                         prefix = "''";
                     char quote = prefix[Inter::prefix_quote];
                     char quote = prefix[Inter::prefix_quote];
-                    for (Code::ByteCode *var = call->getSon(); var != nullptr; var = var->toNext()) {
-                        if (var->getType() != Code::ByteCode::code_element || var->getPrefix() == quote ||
+                    for (aFuncode::Code::ByteCode *var = call->getSon(); var != nullptr; var = var->toNext()) {
+                        if (var->getType() != aFuncode::Code::ByteCode::code_element || var->getPrefix() == quote ||
                             inter.checkLiteral(var->getElement()))
                             inter.checkLiteral(var->getElement()))
                             continue;
                             continue;
                         Object *obj = varlist.findObject(var->getElement());
                         Object *obj = varlist.findObject(var->getElement());

+ 1 - 0
src/core/core-init.cpp

@@ -1,5 +1,6 @@
 #include <clocale>
 #include <clocale>
 #include "core-init.h"
 #include "core-init.h"
+#include "core-logger.h"
 
 
 namespace aFuncore {
 namespace aFuncore {
     aFuntool::Logger *aFunCoreLogger = nullptr;
     aFuntool::Logger *aFunCoreLogger = nullptr;

+ 3 - 3
src/core/inter.cpp

@@ -1,6 +1,6 @@
 #include "inter.h"
 #include "inter.h"
 #include "core-activation.h"
 #include "core-activation.h"
-#include "core-init.h"
+#include "core-logger.h"
 #include "msg.h"
 #include "msg.h"
 #include "core-exception.h"
 #include "core-exception.h"
 
 
@@ -46,7 +46,7 @@ namespace aFuncore {
                 return false;
                 return false;
             }
             }
 
 
-            const Code::ByteCode *code = nullptr;
+            const aFuncode::Code::ByteCode *code = nullptr;
             Activation::ActivationStatus as = activation->getCode(code);
             Activation::ActivationStatus as = activation->getCode(code);
             switch (as) {
             switch (as) {
                 case Activation::as_end: {
                 case Activation::as_end: {
@@ -74,7 +74,7 @@ namespace aFuncore {
      * @param code 代码
      * @param code 代码
      * @return
      * @return
      */
      */
-    bool Inter::runCode(const Code &code){
+    bool Inter::runCode(const aFuncode::Code &code){
         if (activation != nullptr) {
         if (activation != nullptr) {
             errorLog(aFunCoreLogger, "Run code with activation");
             errorLog(aFunCoreLogger, "Run code with activation");
             return false;
             return false;

+ 1 - 1
src/core/lexical.cpp

@@ -4,7 +4,7 @@
  */
  */
 #include <cctype>
 #include <cctype>
 #include "core-parser.h"
 #include "core-parser.h"
-#include "core-init.h"
+#include "core-logger.h"
 #include "inter.h"
 #include "inter.h"
 
 
 #ifndef isascii
 #ifndef isascii

+ 1 - 1
src/core/object-value.cpp

@@ -1,6 +1,6 @@
 #include "object-value.h"
 #include "object-value.h"
 #include "inter.h"
 #include "inter.h"
-#include "core-init.h"
+#include "core-logger.h"
 #include "core-exception.h"
 #include "core-exception.h"
 #include "core-activation.h"
 #include "core-activation.h"
 
 

+ 1 - 1
src/core/object.cpp

@@ -1,6 +1,6 @@
 #include "object.h"
 #include "object.h"
 #include "inter.h"
 #include "inter.h"
-#include "core-init.h"
+#include "core-logger.h"
 
 
 namespace aFuncore {
 namespace aFuncore {
     Object::Object(std::string type_, Inter &inter)
     Object::Object(std::string type_, Inter &inter)

+ 1 - 1
src/core/reader.cpp

@@ -1,4 +1,4 @@
-#include "core-init.h"
+#include "core-logger.h"
 #include "reader.h"
 #include "reader.h"
 
 
 namespace aFuncore {
 namespace aFuncore {

+ 18 - 18
src/core/syntactic.cpp

@@ -1,5 +1,5 @@
 #include "core-parser.h"
 #include "core-parser.h"
-#include "core-init.h"
+#include "core-logger.h"
 
 
 namespace aFuncore {
 namespace aFuncore {
     bool Parser::getToken() {
     bool Parser::getToken() {
@@ -19,18 +19,18 @@ namespace aFuncore {
         return true;
         return true;
     }
     }
 
 
-    Code::ByteCode *Parser::codeSelf(Code &code, size_t depth, char prefix) {  // NOLINT
+    aFuncode::Code::ByteCode *Parser::codeSelf(aFuncode::Code &code, size_t depth, char prefix) {  // NOLINT
         depth++;
         depth++;
         getToken();
         getToken();
         switch (syntactic.token) {
         switch (syntactic.token) {
             case TK_ELEMENT_SHORT:
             case TK_ELEMENT_SHORT:
             case TK_ELEMENT_LONG:
             case TK_ELEMENT_LONG:
-                return new Code::ByteCode(code, syntactic.text, reader.getFileLine(), prefix);
+                return new aFuncode::Code::ByteCode(code, syntactic.text, reader.getFileLine(), prefix);
             case TK_LP: {
             case TK_LP: {
-                Code::ByteCode *code_list;
+                aFuncode::Code::ByteCode *code_list;
                 if (depth <= SYNTACTIC_MAX_DEPTH) {
                 if (depth <= SYNTACTIC_MAX_DEPTH) {
                     code_list = codeList(code, depth);
                     code_list = codeList(code, depth);
-                    code_list = new Code::ByteCode(code, Code::ByteCode::block_p, code_list, reader.getFileLine(), prefix);
+                    code_list = new aFuncode::Code::ByteCode(code, aFuncode::Code::ByteCode::block_p, code_list, reader.getFileLine(), prefix);
                 } else {
                 } else {
                     pushEvent({ParserEvent::syntactic_error_nested_too_deep, reader.getFileLine(), ""});
                     pushEvent({ParserEvent::syntactic_error_nested_too_deep, reader.getFileLine(), ""});
                     syntactic.is_error = true;
                     syntactic.is_error = true;
@@ -47,10 +47,10 @@ namespace aFuncore {
                 return code_list;
                 return code_list;
             }
             }
             case TK_LB: {
             case TK_LB: {
-                Code::ByteCode *code_list;
+                aFuncode::Code::ByteCode *code_list;
                 if (depth <= SYNTACTIC_MAX_DEPTH) {
                 if (depth <= SYNTACTIC_MAX_DEPTH) {
                     code_list = codeList(code, depth);
                     code_list = codeList(code, depth);
-                    code_list = new Code::ByteCode(code, Code::ByteCode::block_b, code_list, reader.getFileLine(), prefix);
+                    code_list = new aFuncode::Code::ByteCode(code, aFuncode::Code::ByteCode::block_b, code_list, reader.getFileLine(), prefix);
                 } else {
                 } else {
                     pushEvent({ParserEvent::syntactic_error_nested_too_deep, reader.getFileLine(), ""});
                     pushEvent({ParserEvent::syntactic_error_nested_too_deep, reader.getFileLine(), ""});
                     syntactic.is_error = true;
                     syntactic.is_error = true;
@@ -67,10 +67,10 @@ namespace aFuncore {
                 return code_list;
                 return code_list;
             }
             }
             case TK_LC: {
             case TK_LC: {
-                Code::ByteCode *code_list;
+                aFuncode::Code::ByteCode *code_list;
                 if (depth <= SYNTACTIC_MAX_DEPTH) {
                 if (depth <= SYNTACTIC_MAX_DEPTH) {
                     code_list = codeList(code, depth);
                     code_list = codeList(code, depth);
-                    code_list = new Code::ByteCode(code, Code::ByteCode::block_c, code_list, reader.getFileLine(), prefix);
+                    code_list = new aFuncode::Code::ByteCode(code, aFuncode::Code::ByteCode::block_c, code_list, reader.getFileLine(), prefix);
                 } else {
                 } else {
                     pushEvent({ParserEvent::syntactic_error_nested_too_deep, reader.getFileLine(), ""});
                     pushEvent({ParserEvent::syntactic_error_nested_too_deep, reader.getFileLine(), ""});
                     syntactic.is_error = true;
                     syntactic.is_error = true;
@@ -95,7 +95,7 @@ namespace aFuncore {
         }
         }
     }
     }
 
 
-    Code::ByteCode *Parser::codePrefix(Code &code, size_t depth) {  // NOLINT
+    aFuncode::Code::ByteCode *Parser::codePrefix(aFuncode::Code &code, size_t depth) {  // NOLINT
         char ch = aFuntool::NUL;
         char ch = aFuntool::NUL;
         getToken();
         getToken();
         if (syntactic.token != TK_PREFIX) {
         if (syntactic.token != TK_PREFIX) {
@@ -110,10 +110,10 @@ namespace aFuncore {
         return codeSelf(code, depth, ch);
         return codeSelf(code, depth, ch);
     }
     }
 
 
-    Code::ByteCode *Parser::codeList(Code &code, size_t depth) {  // NOLINT
-        Code::ByteCode *re = nullptr;
-        Code::ByteCode *new_re = nullptr;
-        Code::ByteCode *code_list;
+    aFuncode::Code::ByteCode *Parser::codeList(aFuncode::Code &code, size_t depth) {  // NOLINT
+        aFuncode::Code::ByteCode *re = nullptr;
+        aFuncode::Code::ByteCode *new_re = nullptr;
+        aFuncode::Code::ByteCode *code_list;
 
 
         while (true) {
         while (true) {
             getToken();
             getToken();
@@ -153,7 +153,7 @@ namespace aFuncore {
         }
         }
     }
     }
 
 
-    Code::ByteCode *Parser::codeListEnd(Code &code) {
+    aFuncode::Code::ByteCode *Parser::codeListEnd(aFuncode::Code &code) {
         getToken();
         getToken();
         switch (syntactic.token) {
         switch (syntactic.token) {
             case TK_EOF:
             case TK_EOF:
@@ -166,7 +166,7 @@ namespace aFuncore {
             case TK_LB:
             case TK_LB:
             case TK_LC: {
             case TK_LC: {
                 goBackToken();
                 goBackToken();
-                Code::ByteCode *re = codeList(code, 0);
+                aFuncode::Code::ByteCode *re = codeList(code, 0);
                 getToken();
                 getToken();
                 if (syntactic.token != TK_EOF && syntactic.token != TK_ERROR) {
                 if (syntactic.token != TK_EOF && syntactic.token != TK_ERROR) {
                     pushEvent({ParserEvent::parser_error_unknown, reader.getFileLine(), ""});
                     pushEvent({ParserEvent::parser_error_unknown, reader.getFileLine(), ""});
@@ -181,8 +181,8 @@ namespace aFuncore {
         }
         }
     }
     }
 
 
-    bool Parser::parserCode(Code &code) {
-        Code::ByteCode *bytecode = codeListEnd(code);
+    bool Parser::parserCode(aFuncode::Code &code) {
+        aFuncode::Code::ByteCode *bytecode = codeListEnd(code);
         code.getByteCode()->connect(bytecode);
         code.getByteCode()->connect(bytecode);
         
         
         if (syntactic.is_error || reader.isError() || lexical.is_error)
         if (syntactic.is_error || reader.isError() || lexical.is_error)

+ 11 - 16
src/interface/CMakeLists.txt

@@ -2,10 +2,6 @@
      LIST_DIRECTORIES FALSE
      LIST_DIRECTORIES FALSE
      ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
      ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
 
 
-file(GLOB private_h
-     LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/*.h)
-
 file(GLOB public_h
 file(GLOB public_h
      LIST_DIRECTORIES FALSE
      LIST_DIRECTORIES FALSE
      RELATIVE "${build_include_runtime}"
      RELATIVE "${build_include_runtime}"
@@ -20,12 +16,12 @@ foreach(h IN LISTS public_h)
     list(APPEND public_h_install "$<INSTALL_INTERFACE:${install_include_runtime}/${h}>")
     list(APPEND public_h_install "$<INSTALL_INTERFACE:${install_include_runtime}/${h}>")
 endforeach()
 endforeach()
 
 
-add_library(rt-shared SHARED "")  # xx表示均为动态链接 core-share-t
-add_library(rt-static STATIC "")  # ct表示均静态链接 core-static
+add_library(it-shared SHARED "")  # xx表示均为动态链接 core-share-t
+add_library(it-static STATIC "")  # ct表示均静态链接 core-static
 
 
-foreach(tgt rt-shared rt-static)
+foreach(tgt it-shared it-static)
     target_sources(${tgt}
     target_sources(${tgt}
-                   PRIVATE ${source} ${private_h}
+                   PRIVATE ${source}
                    PUBLIC ${public_h_build} ${public_h_install})
                    PUBLIC ${public_h_build} ${public_h_install})
     target_include_directories(${tgt}
     target_include_directories(${tgt}
                                PRIVATE
                                PRIVATE
@@ -35,19 +31,18 @@ foreach(tgt rt-shared rt-static)
                                    ${build_include}
                                    ${build_include}
                                    ${install_include})
                                    ${install_include})
     set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}")
     set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}")
-    define_FILENAME(${tgt})
+    define_filename(${tgt})
 endforeach()
 endforeach()
 
 
-set_target_properties(rt-shared PROPERTIES OUTPUT_NAME "aFunit")
-set_target_properties(rt-static PROPERTIES OUTPUT_NAME "aFunit-s")
+set_target_properties(it-shared PROPERTIES OUTPUT_NAME "aFunit")
+set_target_properties(it-static PROPERTIES OUTPUT_NAME "aFunit-s")
 
 
-target_link_libraries(rt-shared PUBLIC core-shared)
-target_link_libraries(rt-static PUBLIC core-static)
+target_link_libraries(it-shared PUBLIC core-shared)
+target_link_libraries(it-static PUBLIC core-static)
 
 
-#install(TARGETS rt-shared rt-static
+#install(TARGETS it-shared it-static
 #        EXPORT aFunlang
 #        EXPORT aFunlang
 #        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
 #        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
 #        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
 #        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
 #        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
 #        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
-#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev
-#        PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT advanced-dev)
+#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev)

+ 2 - 2
src/tool/CMakeLists.txt

@@ -55,9 +55,9 @@ foreach(tgt tool-shared tool-static tool-shared-c tool-static-c)
     target_sources(${tgt} PRIVATE ${source} ${private_h} PUBLIC ${public_h_build} ${public_h_install})
     target_sources(${tgt} PRIVATE ${source} ${private_h} PUBLIC ${public_h_build} ${public_h_install})
     target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
     target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
     target_compile_definitions(${tgt} PUBLIC ${definitions})
     target_compile_definitions(${tgt} PUBLIC ${definitions})
-    set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}")
+    set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}" PRIVATE_HEADER "${private_h}")
     target_link_libraries(${tgt} PUBLIC ${dlfcn_lib} PCRE2::8BIT Threads::Threads)
     target_link_libraries(${tgt} PUBLIC ${dlfcn_lib} PCRE2::8BIT Threads::Threads)
-    define_FILENAME(${tgt})
+    define_filename(${tgt})
 endforeach()
 endforeach()
 
 
 foreach(tgt tool-shared tool-static)
 foreach(tgt tool-shared tool-static)

+ 1 - 1
test/lib/CMakeLists.txt

@@ -6,6 +6,6 @@ foreach(src IN LISTS src_list)
     add_library(${file_name} SHARED ${src})
     add_library(${file_name} SHARED ${src})
     set_target_properties(${file_name}
     set_target_properties(${file_name}
                           PROPERTIES OUTPUT_NAME "test-lib-${file_name}")
                           PROPERTIES OUTPUT_NAME "test-lib-${file_name}")
-    define_FILENAME(${file_name})
+    define_filename(${file_name})
     unset(file_name)
     unset(file_name)
 endforeach()
 endforeach()

+ 3 - 3
test/src/CMakeLists.txt

@@ -4,11 +4,11 @@ foreach(src IN LISTS src_list)
     cmake_path(GET src STEM file_name)
     cmake_path(GET src STEM file_name)
     add_executable(${file_name})
     add_executable(${file_name})
     target_sources(${file_name} PRIVATE ${src})
     target_sources(${file_name} PRIVATE ${src})
-    target_link_libraries(${file_name} PUBLIC tool-static core-static rt-static)  # 链接静态库 (导出所有符号)
+    target_link_libraries(${file_name} PUBLIC tool-static code-static core-static it-static)  # 链接静态库 (导出所有符号)
     set_target_properties(${file_name}
     set_target_properties(${file_name}
                           PROPERTIES OUTPUT_NAME "test-${file_name}")
                           PROPERTIES OUTPUT_NAME "test-${file_name}")
     target_compile_definitions(${file_name} PRIVATE IN_CTEST)
     target_compile_definitions(${file_name} PRIVATE IN_CTEST)
-    define_FILENAME(${file_name})
+    define_filename(${file_name})
     unset(file_name)
     unset(file_name)
 endforeach()
 endforeach()
 unset(src_list)
 unset(src_list)
@@ -23,7 +23,7 @@ foreach(src IN LISTS src_list)
     set_target_properties(${file_name}
     set_target_properties(${file_name}
             PROPERTIES OUTPUT_NAME "test-${file_name}")
             PROPERTIES OUTPUT_NAME "test-${file_name}")
     target_compile_definitions(${file_name} PRIVATE IN_CTEST)
     target_compile_definitions(${file_name} PRIVATE IN_CTEST)
-    define_FILENAME(${file_name})
+    define_filename(${file_name})
     unset(file_name)
     unset(file_name)
 endforeach()
 endforeach()
 unset(src_list)
 unset(src_list)

+ 2 - 2
test/src/core-code.cpp

@@ -1,5 +1,5 @@
-#include "code.h"
-using namespace aFuncore;
+#include "aFuncode.h"
+using namespace aFuncode;
 using namespace aFuntool;
 using namespace aFuntool;
 
 
 int main() {
 int main() {

+ 4 - 4
test/src/it-syntactic.cpp

@@ -91,7 +91,7 @@ int main(int argc, char **) {
     {
     {
         auto reader = aFunit::StringReader(str, "str");
         auto reader = aFunit::StringReader(str, "str");
         auto parser = aFuncore::Parser(reader);
         auto parser = aFuncore::Parser(reader);
-        auto code = aFuncore::Code("test.aun");
+        auto code = aFuncode::Code("test.aun");
         bool ret = parser.parserCode(code);
         bool ret = parser.parserCode(code);
         if (!ret)
         if (!ret)
             return 1;
             return 1;
@@ -103,7 +103,7 @@ int main(int argc, char **) {
     {
     {
         auto reader = aFunit::StringReader(str2, "str2");
         auto reader = aFunit::StringReader(str2, "str2");
         auto parser = aFuncore::Parser(reader);
         auto parser = aFuncore::Parser(reader);
-        auto code = aFuncore::Code("test2.aun");
+        auto code = aFuncode::Code("test2.aun");
         parser.parserCode(code);
         parser.parserCode(code);
 
 
         while (parser.countEvent() != 0) {
         while (parser.countEvent() != 0) {
@@ -123,7 +123,7 @@ int main(int argc, char **) {
 
 
         auto reader = aFunit::FileReader("test.aun");
         auto reader = aFunit::FileReader("test.aun");
         auto parser = aFuncore::Parser(reader);
         auto parser = aFuncore::Parser(reader);
-        auto code = aFuncore::Code("test.aun");
+        auto code = aFuncode::Code("test.aun");
         bool ret = parser.parserCode(code);
         bool ret = parser.parserCode(code);
         if (!ret)
         if (!ret)
             return 1;
             return 1;
@@ -140,7 +140,7 @@ int main(int argc, char **) {
     {
     {
         auto reader = ConsoleReader(nothing, "stdin.aun");
         auto reader = ConsoleReader(nothing, "stdin.aun");
         auto parser = aFuncore::Parser(reader);
         auto parser = aFuncore::Parser(reader);
-        auto code = aFuncore::Code("stdin.aun");
+        auto code = aFuncode::Code("stdin.aun");
         bool ret = parser.parserCode(code);
         bool ret = parser.parserCode(code);
 
 
         if (ret) {
         if (ret) {

+ 1 - 0
test/src/run-code.cpp

@@ -2,6 +2,7 @@
 
 
 using namespace aFunit;
 using namespace aFunit;
 using namespace aFuncore;
 using namespace aFuncore;
+using namespace aFuncode;
 using namespace aFuntool;
 using namespace aFuntool;
 
 
 void progressInterEvent(Inter &inter);
 void progressInterEvent(Inter &inter);