Forráskód Böngészése

refactor: core模块提出inline和template

SongZihuan 3 éve
szülő
commit
c645d69bc7

+ 12 - 10
include/core/activation.h

@@ -26,15 +26,15 @@ namespace aFuncore {
 
         virtual ActivationStatus getCode(Code *&code) = 0;
         virtual void runCode(Code *code);
-        virtual void endRun() {}
+        virtual void endRun();
 
-        [[nodiscard]] VarList *getVarlist() const {return varlist;}
-        [[nodiscard]] Activation *toPrev() const {return prev;}
-        [[nodiscard]] UpMessage *getUpStream() const {return up;}
-        [[nodiscard]] DownMessage *getDownStream() const {return down;}
+        [[nodiscard]] VarList *getVarlist() const;
+        [[nodiscard]] Activation *toPrev() const;
+        [[nodiscard]] UpMessage *getUpStream() const;
+        [[nodiscard]] DownMessage *getDownStream() const;
 
-        [[nodiscard]] FileLine getFileLine() const {return line;}
-        [[nodiscard]] const StringFilePath &getFilePath() const {return path;}
+        [[nodiscard]] FileLine getFileLine() const;
+        [[nodiscard]] const StringFilePath &getFilePath() const;
     };
 
     class AFUN_CORE_EXPORT ExeActivation : public Activation {
@@ -42,9 +42,9 @@ namespace aFuncore {
         Code *next;
         bool first=true;
     public:
-        explicit ExeActivation(Code *code, Inter *inter_) : Activation(inter_), start{code}, next{code} {}
+        explicit ExeActivation(Code *code, Inter *inter_);
         ActivationStatus getCode(Code *&code) override;
-        [[nodiscard]] Code *getStart() const {return start;}
+        [[nodiscard]] Code *getStart() const;
     };
 
     class AFUN_CORE_EXPORT TopActivation : public ExeActivation {
@@ -70,11 +70,13 @@ namespace aFuncore {
         std::list<Function::CallFunction::ArgCodeList>::iterator acl_begin;
         std::list<Function::CallFunction::ArgCodeList>::iterator acl_end;
     public:
-        explicit FuncActivation(Code *code, Inter *inter_) : Activation(inter_), call{code,} {}
+        explicit FuncActivation(Code *code, Inter *inter_);
         ~FuncActivation() override;
         ActivationStatus getCode(Code *&code) override;
         void endRun() override;
     };
 }
 
+#include "activation.inline.h"
+
 #endif //AFUN_ACTIVATION_H

+ 48 - 0
include/core/activation.inline.h

@@ -0,0 +1,48 @@
+#ifndef AFUN_ACTIVATION_INLINE_H
+#define AFUN_ACTIVATION_INLINE_H
+
+#include "activation.h"
+
+namespace aFuncore {
+    inline void Activation::endRun() {
+
+    }
+
+    inline VarList *Activation::getVarlist() const{
+        return varlist;
+    }
+
+    inline Activation *Activation::toPrev() const{
+        return prev;
+    }
+
+    inline UpMessage *Activation::getUpStream() const{
+        return up;
+    }
+
+    inline DownMessage *Activation::getDownStream() const{
+        return down;
+    }
+
+    inline FileLine Activation::getFileLine() const{
+        return line;
+    }
+
+    inline const StringFilePath &Activation::getFilePath() const{
+        return path;
+    }
+
+    inline ExeActivation::ExeActivation(Code *code, Inter *inter_) : Activation(inter_), start{code}, next{code}{
+
+    }
+
+    inline Code *ExeActivation::getStart() const{
+        return start;
+    }
+
+    inline FuncActivation::FuncActivation(Code *code, Inter *inter_) : Activation(inter_), call{code,}{
+
+    }
+}
+
+#endif //AFUN_ACTIVATION_INLINE_H

+ 15 - 22
include/core/code.h

@@ -33,20 +33,11 @@ namespace aFuncore {
         Code(const Code &)=delete;
         Code &operator=(const Code &)=delete;
 
-        static Code *create(FileLine line, ConstFilePath file="") {
-            return new Code(line, file);
-        }
-
+        static Code *create(FileLine line, ConstFilePath file="");
         static Code *create(const std::string &element,
-                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL) {
-            return new Code(element, line, file, prefix);
-        }
-
+                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
         static Code *create(BlockType block_type, Code *son,
-                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL) {
-            return new Code(block_type, son, line, file);
-        }
-
+                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
         static void destruct(Code *code);
 
         Code *connect(Code *code);
@@ -61,20 +52,22 @@ namespace aFuncore {
         bool writeByteCode(ConstFilePath file_path, bool debug=false) const;  // NOLINT 允许忽略返回值
         bool readByteCode(ConstFilePath file_path);
 
-        [[nodiscard]] CodeType getType() const {return type;}
-        [[nodiscard]] char getPrefix() const {return prefix;}
+        [[nodiscard]] CodeType getType() const;
+        [[nodiscard]] char getPrefix() const;
 
-        [[nodiscard]] const char *getElement() const {if (type != code_element) return ""; return element;}
-        [[nodiscard]] BlockType getBlockType() const {if (type != code_block) return block_p; return block_type;}
-        [[nodiscard]] Code *getSon() const {if (type != code_block) return nullptr; return son;}
+        [[nodiscard]] const char *getElement() const;
+        [[nodiscard]] BlockType getBlockType() const;
+        [[nodiscard]] Code *getSon() const;
 
-        [[nodiscard]] Code *toNext() const {return next;}
-        [[nodiscard]] Code *toPrev() const {return prev;}
-        [[nodiscard]] Code *toFather() const {return father;}
+        [[nodiscard]] Code *toNext() const;
+        [[nodiscard]] Code *toPrev() const;
+        [[nodiscard]] Code *toFather() const;
 
-        [[nodiscard]] aFuntool::FileLine getFileLine() const {return line;}
-        [[nodiscard]] aFuntool::FilePath getFilePath() const {return file;}
+        [[nodiscard]] aFuntool::FileLine getFileLine() const;
+        [[nodiscard]] aFuntool::FilePath getFilePath() const;
     };
 }
 
+#include "code.inline.h"
+
 #endif //AFUN_CODE_H

+ 67 - 0
include/core/code.inline.h

@@ -0,0 +1,67 @@
+#ifndef AFUN_CODE_INLINE_H
+#define AFUN_CODE_INLINE_H
+#include "code.h"
+
+namespace aFuncore {
+    inline Code *Code::create(FileLine line, ConstFilePath file) {
+        return new Code(line, file);
+    }
+
+    inline Code *Code::create(const std::string &element,
+                    aFuntool::FileLine line, aFuntool::ConstFilePath file, char prefix) {
+        return new Code(element, line, file, prefix);
+    }
+
+    inline Code *Code::create(BlockType block_type, Code *son,
+                    aFuntool::FileLine line, aFuntool::ConstFilePath file, char prefix) {
+        return new Code(block_type, son, line, file);
+    }
+
+    inline CodeType Code::getType() const {
+        return type;
+    }
+
+    inline char Code::getPrefix() const {
+        return prefix;
+    }
+
+    inline const char *Code::getElement() const {
+        if (type != code_element)
+            return "";
+        return element;
+    }
+
+    inline BlockType Code::getBlockType() const {
+        if (type != code_block)
+            return block_p;
+        return block_type;
+    }
+
+    inline Code *Code::getSon() const {
+        if (type != code_block)
+            return nullptr;
+        return son;
+    }
+
+    inline Code *Code::toNext() const {
+        return next;
+    }
+
+    inline Code *Code::toPrev() const {
+        return prev;
+    }
+
+    inline Code *Code::toFather() const {
+        return father;
+    }
+
+    inline aFuntool::FileLine Code::getFileLine() const {
+        return line;
+    }
+
+    inline aFuntool::FilePath Code::getFilePath() const {
+        return file;
+    }
+}
+
+#endif //AFUN_CODE_INLINE_H

+ 2 - 1
include/core/env-var.h

@@ -22,7 +22,7 @@ namespace aFuncore {
         EnvVarSpace(const EnvVarSpace &)=delete;
         EnvVarSpace &operator=(const EnvVarSpace &)=delete;
 
-        [[nodiscard]] size_t getCount() const {return count;}
+        [[nodiscard]] size_t getCount() const;
         bool findString(const std::string &name, std::string &str) const;
         bool findNumber(const std::string &name, int32_t &num) const;
 
@@ -31,5 +31,6 @@ namespace aFuncore {
     };
 }
 
+#include "env-var.inline.h"
 
 #endif //AFUN_ENV_VAR_H

+ 11 - 0
include/core/env-var.inline.h

@@ -0,0 +1,11 @@
+#ifndef AFUN_ENV_VAR_INLINE_H
+#define AFUN_ENV_VAR_INLINE_H
+#include "env-var.h"
+
+namespace aFuncore {
+    inline size_t EnvVarSpace::getCount() const{
+        return count;
+    }
+}
+
+#endif //AFUN_ENV_VAR_INLINE_H

+ 11 - 39
include/core/gc.h

@@ -12,47 +12,17 @@ namespace aFuncore {
         bool reachable;  // 可达标记 [同时标识已迭代]
         GcCount reference;  // 引用计数
     protected:
-        GcObjectBase() : not_clear{false}, reference{0}, reachable{false} {}
+        GcObjectBase();
         virtual ~GcObjectBase() = default;
-        GcObjectBase(const GcObjectBase &)=delete;
-        GcObjectBase &operator=(const GcObjectBase &)=delete;
+        GcObjectBase(const GcObjectBase &) = delete;
+        GcObjectBase &operator=(const GcObjectBase &) = delete;
     public:
-        void addReference() {reference++;}
-        void delReference() {reference--;}
-        void setClear(bool clear=false) {not_clear=!clear;}
-        void setReachable(bool is_reference=false) {reachable=is_reference;}
+        void addReference();
+        void delReference();
+        void setClear(bool clear=false);
+        void setReachable(bool is_reference=false);
     };
 
-    template <class T>
-    class GcObject : public GcObjectBase {
-        T *prev;
-        T *next;
-    protected:
-        GcObject() : GcObjectBase(), prev {nullptr}, next {nullptr} {}
-    public:
-        void addObject(T *&chain) {
-            if (chain != nullptr) {
-                next = chain;
-                chain->prev = dynamic_cast<T *>(this);
-            }
-            chain = dynamic_cast<T *>(this);
-        }
-        void delObject(T *&chain) {
-            if (next != nullptr)
-                next->prev = prev;
-
-            if (prev == nullptr)
-                chain = next;
-            else
-                prev->next = next;
-        }
-        static void destruct(T *&chain) {
-            for (T *tmp = chain, *n; tmp != nullptr; tmp = n) {
-                n = tmp->next;
-                delete tmp;
-            }
-        }
-    };
 
     class AFUN_CORE_EXPORT GcList {
         std::queue<GcObjectBase *> queue;
@@ -60,11 +30,13 @@ namespace aFuncore {
         size_t add(GcObjectBase *obj);
         GcObjectBase *pop();
 
-        [[nodiscard]] size_t getSize() const {return queue.size();}
-        [[nodiscard]] size_t isEmpty() const {return queue.empty();}
+        [[nodiscard]] size_t getSize() const;
+        [[nodiscard]] size_t isEmpty() const;
     };
 
 };
 
+#include "gc.inline.h"
+#include "gc.template.h"
 
 #endif //AFUN_GC_H

+ 36 - 0
include/core/gc.inline.h

@@ -0,0 +1,36 @@
+#ifndef AFUN_GC_INLINE_H
+#define AFUN_GC_INLINE_H
+#include "gc.h"
+
+namespace aFuncore {
+    inline GcObjectBase::GcObjectBase() : not_clear{false}, reference{0}, reachable{false} {
+
+    }
+
+    inline void GcObjectBase::addReference() {
+        reference++;
+    }
+
+    inline void GcObjectBase::delReference() {
+        reference--;
+    }
+
+    inline void GcObjectBase::setClear(bool clear) {
+        not_clear=!clear;
+    }
+
+    inline void GcObjectBase::setReachable(bool is_reference) {
+        reachable=is_reference;
+    }
+
+
+    inline size_t GcList::getSize() const {
+        return queue.size();
+    }
+
+    inline size_t GcList::isEmpty() const {
+        return queue.empty();
+    }
+}
+
+#endif //AFUN_GC_INLINE_H

+ 42 - 0
include/core/gc.template.h

@@ -0,0 +1,42 @@
+#ifndef AFUN_GC_TEMPLATE_H
+#define AFUN_GC_TEMPLATE_H
+
+#include "gc.h"
+
+namespace aFuncore {
+    template<class T>
+    class GcObject : public GcObjectBase {
+        T *prev;
+        T *next;
+    protected:
+        GcObject() : GcObjectBase(), prev{nullptr}, next{nullptr}{}
+
+    public:
+        void addObject(T *&chain){
+            if (chain != nullptr) {
+                next = chain;
+                chain->prev = dynamic_cast<T *>(this);
+            }
+            chain = dynamic_cast<T *>(this);
+        }
+
+        void delObject(T *&chain){
+            if (next != nullptr)
+                next->prev = prev;
+
+            if (prev == nullptr)
+                chain = next;
+            else
+                prev->next = next;
+        }
+
+        static void destruct(T *&chain){
+            for (T *tmp = chain, *n; tmp != nullptr; tmp = n) {
+                n = tmp->next;
+                delete tmp;
+            }
+        }
+    };
+}
+
+#endif //AFUN_GC_TEMPLATE_H

+ 11 - 9
include/core/inter.h

@@ -22,14 +22,14 @@ namespace aFuncore {
             Var *var;
             VarSpace *varspace;
         } *gc;
-        [[nodiscard]] struct GcRecord *getGcRecord() const {return gc;}
+        [[nodiscard]] struct GcRecord *getGcRecord() const;
 
         /* 运行相关 */
         ProtectVarSpace *protect;  // 保护变量空间
         VarSpace *global;  // 全局变量空间
         VarList *global_varlist;  // global + protect
         Activation *activation;  // 活动记录
-        void pushActivation(Activation *new_activation) {activation = new_activation;}
+        void pushActivation(Activation *new_activation);
 
         struct LiteralRegex {
             Regex *rg;
@@ -63,16 +63,16 @@ namespace aFuncore {
 
         void enable();
 
-        [[nodiscard]] InterStatus getStatus() const {return status;}
-        [[nodiscard]] bool isExit() const {return (status == inter_exit || status == inter_stop);}
+        [[nodiscard]] InterStatus getStatus() const;
+        [[nodiscard]] bool isExit() const;
 
-        [[nodiscard]] ProtectVarSpace *getProtectVarSpace() const {return protect;}
-        [[nodiscard]] VarSpace *getGlobalVarSpace() const {return global;}
-        [[nodiscard]] VarList *getGlobalVarlist() const {return global_varlist;}
-        [[nodiscard]] Activation *getActivation() const {return activation;}
+        [[nodiscard]] ProtectVarSpace *getProtectVarSpace() const;
+        [[nodiscard]] VarSpace *getGlobalVarSpace() const;
+        [[nodiscard]] VarList *getGlobalVarlist() const;
+        [[nodiscard]] Activation *getActivation() const;
         [[nodiscard]] bool checkLiteral(const std::string &element) const;
         [[nodiscard]] bool checkLiteral(const std::string &element, std::string &literaler, bool &in_protect) const;
-        [[nodiscard]] EnvVarSpace *getEnvVarSpace() const {return envvar;}
+        [[nodiscard]] EnvVarSpace *getEnvVarSpace() const;
 
         bool pushLiteral(const std::string &pattern, const std::string &literaler, bool in_protect);
 
@@ -81,4 +81,6 @@ namespace aFuncore {
     };
 }
 
+#include "inter.inline.h"
+
 #endif //AFUN_INTER_H

+ 43 - 0
include/core/inter.inline.h

@@ -0,0 +1,43 @@
+#ifndef AFUN_INTER_INLINE_H
+#define AFUN_INTER_INLINE_H
+#include "inter.h"
+
+namespace aFuncore {
+    inline Inter::GcRecord *Inter::getGcRecord() const {
+        return gc;
+    }
+
+    inline void Inter::pushActivation(Activation *new_activation) {
+        activation = new_activation;
+    }
+
+    inline InterStatus Inter::getStatus() const {
+        return status;
+    }
+
+    inline bool Inter::isExit() const {
+        return (status == inter_exit || status == inter_stop);
+    }
+
+    inline ProtectVarSpace *Inter::getProtectVarSpace() const {
+        return protect;
+    }
+
+    inline VarSpace *Inter::getGlobalVarSpace() const {
+        return global;
+    }
+
+    inline VarList *Inter::getGlobalVarlist() const {
+        return global_varlist;
+    }
+
+    inline Activation *Inter::getActivation() const {
+        return activation;
+    }
+
+    inline EnvVarSpace *Inter::getEnvVarSpace() const {
+        return envvar;
+    }
+}
+
+#endif //AFUN_INTER_INLINE_H

+ 10 - 16
include/core/msg.h

@@ -14,24 +14,24 @@ namespace aFuncore {
         Message *next;  // 下一条消息
     public:
         const std::string type;  // 消息类型标注
-        explicit Message(const std::string &type_) : type {type_}, next {nullptr} {}
+        explicit Message(const std::string &type_);
         virtual ~Message() = default;
         Message &operator=(const Message &)=delete;
     };
 
     class TopMessage : public Message {
     public:
-        explicit TopMessage(const std::string &type_) : Message(type_) {}
+        explicit TopMessage(const std::string &type_);
         virtual void topProgress() = 0;
     };
 
     class AFUN_CORE_EXPORT NormalMessage : public TopMessage {
         Object *obj;
     public:
-        explicit NormalMessage(Object *obj_) : TopMessage("NORMAL"), obj {obj_} {}
+        explicit NormalMessage(Object *obj_);
         ~NormalMessage() override;
         void topProgress() override;
-        Object *getObject() {return obj;}
+        Object *getObject();
     };
 
     class AFUN_CORE_EXPORT ErrorMessage : public TopMessage {
@@ -47,8 +47,8 @@ namespace aFuncore {
     public:
         explicit ErrorMessage(const std::string &error_type_, const std::string &error_info_, Activation *activation);
         void topProgress() override;
-        std::string getErrorType() {return error_type;}
-        std::string getErrorInfo() {return error_info;}
+        std::string getErrorType();
+        std::string getErrorInfo();
     };
 
     class AFUN_CORE_EXPORT MessageStream {
@@ -61,21 +61,13 @@ namespace aFuncore {
         MessageStream &operator=(const MessageStream &)=delete;
 
         template<class T>
-        [[nodiscard]] T *getMessage(const std::string &type) const {
-            Message *msg = this->_getMessage(type);
-            T *ret = dynamic_cast<T*>(msg);
-            return ret;
-        }
+        [[nodiscard]] T *getMessage(const std::string &type) const;
 
         virtual Message *popMessage(const std::string &type);
         void pushMessage(Message *msg);
 
         template <typename T>
-        void forEach(void (*func)(Message *, T), T arg) {
-            for (Message *msg = stream; msg != nullptr; msg = msg->next) {
-                func(msg, arg);
-            }
-        }
+        void forEach(void (*func)(Message *, T), T arg);
     };
 
     class AFUN_CORE_EXPORT UpMessage : public MessageStream {
@@ -94,5 +86,7 @@ namespace aFuncore {
     };
 }
 
+#include "msg.inline.h"
+#include "msg.template.h"
 
 #endif //AFUN_MSG_H

+ 26 - 0
include/core/msg.inline.h

@@ -0,0 +1,26 @@
+#ifndef AFUN_MSG_INLINE_H
+#define AFUN_MSG_INLINE_H
+#include "msg.h"
+
+namespace aFuncore {
+    inline Message::Message(const std::string &type_) : type {type_}, next {nullptr} {
+
+    }
+
+    inline TopMessage::TopMessage(const std::string &type_) : Message(type_) {
+
+    }
+
+    inline NormalMessage::NormalMessage(Object *obj_) : TopMessage("NORMAL"), obj {obj_} {
+
+    }
+
+    inline Object *NormalMessage::getObject() {
+        return obj;
+    }
+
+    inline std::string ErrorMessage::getErrorType() {return error_type;}
+    inline std::string ErrorMessage::getErrorInfo() {return error_info;}
+}
+
+#endif //AFUN_MSG_INLINE_H

+ 22 - 0
include/core/msg.template.h

@@ -0,0 +1,22 @@
+#ifndef AFUN_MSG_TEMPLATE_H
+#define AFUN_MSG_TEMPLATE_H
+#include "msg.h"
+
+namespace aFuncore {
+    template<class T>
+    T *MessageStream::getMessage(const std::string &type) const {
+        Message *msg = this->_getMessage(type);
+        T *ret = dynamic_cast<T*>(msg);
+        return ret;
+    }
+
+
+    template <typename T>
+    void MessageStream::forEach(void (*func)(Message *, T), T arg) {
+        for (Message *msg = stream; msg != nullptr; msg = msg->next) {
+            func(msg, arg);
+        }
+    }
+}
+
+#endif //AFUN_MSG_TEMPLATE_H

+ 8 - 8
include/core/value.h

@@ -18,8 +18,6 @@ namespace aFuncore {
 
     class AFUN_CORE_EXPORT Function : public Object {
     public:
-        Function(const std::string &type_, Inter *inter_) : Object(type_ + ":Function", inter_) {}
-
         class AFUN_CORE_EXPORT CallFunction {
         public:
             struct ArgCodeList {
@@ -34,24 +32,26 @@ namespace aFuncore {
             virtual std::list<ArgCodeList> *getArgCodeList() = 0;
             virtual void runFunction() = 0;
         };
+
+        Function(const std::string &type_, Inter *inter_);
         virtual CallFunction *getCallFunction(Code *code, Inter *inter) = 0;
-        virtual bool isInfix() {return false;}
+        virtual bool isInfix();
     };
 
     class AFUN_CORE_EXPORT Literaler : public Object {
     public:
-        Literaler(const std::string &type_, Inter *inter_) : Object(type_ + ":Literaler", inter_) {}
-
+        Literaler(const std::string &type_, Inter *inter_);
         virtual void getObject(const std::string &literal, char prefix) = 0;
     };
 
     class AFUN_CORE_EXPORT CallBackVar : public Object {
     public:
-        CallBackVar(const std::string &type_, Inter *inter_) : Object(type_ + ":CallBackVar", inter_) {}
-
-        virtual bool isCallBack() {return true;}
+        CallBackVar(const std::string &type_, Inter *inter_);
+        virtual bool isCallBack();
         virtual void callBack() = 0;
     };
 };
 
+#include "value.inline.h"
+
 #endif //AFUN_VALUE_H

+ 27 - 0
include/core/value.inline.h

@@ -0,0 +1,27 @@
+#ifndef AFUN_VALUE_INLINE_H
+#define AFUN_VALUE_INLINE_H
+#include "value.h"
+
+namespace aFuncore {
+    inline Function::Function(const std::string &type_, Inter *inter_) : Object(type_ + ":Function", inter_) {
+
+    }
+
+    inline bool Function::isInfix() {
+        return false;
+    }
+
+    inline Literaler::Literaler(const std::string &type_, Inter *inter_) : Object(type_ + ":Literaler", inter_) {
+
+    }
+
+    inline CallBackVar::CallBackVar(const std::string &type_, Inter *inter_) : Object(type_ + ":CallBackVar", inter_) {
+
+    }
+
+    inline bool CallBackVar::isCallBack() {
+        return true;
+    }
+};
+
+#endif //AFUN_VALUE_INLINE_H

+ 15 - 19
include/core/var.h

@@ -13,10 +13,10 @@ namespace aFuncore {
         Inter *const inter;
 
         Var(Object *data_, Inter *inter_);
-        ~Var() override =default;
+        ~Var() override = default;
 
-        [[nodiscard]] virtual Object *getData() {return data;}
-        virtual void setData(Object *data_) {data = data_;}
+        [[nodiscard]] virtual Object *getData();
+        virtual void setData(Object *data_);
     };
 
     class AFUN_CORE_EXPORT VarSpace : public GcObject<class VarSpace> {
@@ -35,26 +35,23 @@ namespace aFuncore {
         explicit VarSpace(Inter *inter_);
         ~VarSpace() override;
 
-        [[nodiscard]] size_t getCount() const {return count;}
+        [[nodiscard]] size_t getCount() const;
         [[nodiscard]] virtual Var *findVar(const std::string &name);
         virtual VarOperationFlat defineVar(const std::string &name, Object *data);
         virtual VarOperationFlat defineVar(const std::string &name, Var *data);
         virtual VarOperationFlat setVar(const std::string &name, Object *data);
         virtual VarOperationFlat delVar(const std::string &name);
 
-        [[nodiscard]] Object *findObject(const std::string &name) {
-            Var *ret = findVar(name);
-            return ret ? ret->getData() : nullptr;
-        }
+        [[nodiscard]] Object *findObject(const std::string &name);
     };
 
     class AFUN_CORE_EXPORT ProtectVarSpace : public VarSpace {
         bool is_protect;
     public:
-        explicit ProtectVarSpace(Inter *inter_) : VarSpace(inter_), is_protect{false} {}
+        explicit ProtectVarSpace(Inter *inter_);
 
-        [[nodiscard]]bool getProtect() const {return is_protect;};
-        bool setProtect(bool protect) {bool ret = is_protect; is_protect = protect; return ret;}
+        [[nodiscard]] bool getProtect() const;
+        bool setProtect(bool protect);
 
         VarOperationFlat defineVar(const std::string &name, Object *data) override;
         VarOperationFlat defineVar(const std::string &name, Var *data) override;
@@ -67,24 +64,23 @@ namespace aFuncore {
     public:
         explicit VarList() = default;
         explicit VarList(VarList *varlist);
-        explicit VarList(VarSpace *varspace) {this->varspace.push_front(varspace);}
+        explicit VarList(VarSpace *varspace);
         ~VarList() = default;
-        VarList(const VarList &)=delete;
-        VarList &operator=(const VarList &)=delete;
+        VarList(const VarList &) = delete;
+        VarList &operator=(const VarList &) = delete;
 
         void connect(VarList *varlist);
-        void push(VarSpace *varspace_) {varspace.push_front(varspace_);}
+        void push(VarSpace *varspace_);
 
         [[nodiscard]] virtual Var *findVar(const std::string &name);
         virtual bool defineVar(const std::string &name, Object *data);
         virtual bool defineVar(const std::string &name, Var *data);
         virtual bool setVar(const std::string &name, Object *data);
         virtual bool delVar(const std::string &name);
-        [[nodiscard]] Object *findObject(const std::string &name) {
-            Var *var = findVar(name);
-            return var ? var->getData() : nullptr;
-        }
+        [[nodiscard]] Object *findObject(const std::string &name);
     };
 }
 
+#include "var.inline.h"
+
 #endif //AFUN_VAR_H

+ 47 - 0
include/core/var.inline.h

@@ -0,0 +1,47 @@
+#ifndef AFUN_VAR_INLINE_H
+#define AFUN_VAR_INLINE_H
+#include "var.h"
+
+namespace aFuncore {
+    inline Object *Var::getData() {
+        return data;
+    }
+
+    inline void Var::setData(Object *data_) {
+        data = data_;
+    }
+
+    inline size_t VarSpace::getCount() const {return count;}
+
+    inline Object *VarSpace::findObject(const std::string &name) {
+        Var *ret = findVar(name);
+        return ret ? ret->getData() : nullptr;
+    }
+
+    inline ProtectVarSpace::ProtectVarSpace(Inter *inter_) : VarSpace(inter_), is_protect{false} {
+
+    }
+
+    inline bool ProtectVarSpace::getProtect() const {
+        return is_protect;
+    }
+
+    inline bool ProtectVarSpace::setProtect(bool protect) {
+        bool ret = is_protect; is_protect = protect; return ret;
+    }
+
+    inline VarList::VarList(VarSpace *varspace) {
+        this->varspace.push_front(varspace);
+    }
+
+    inline void VarList::push(VarSpace *varspace_) {
+        varspace.push_front(varspace_);
+    }
+
+    inline Object *VarList::findObject(const std::string &name) {
+        Var *var = findVar(name);
+        return var ? var->getData() : nullptr;
+    }
+}
+
+#endif //AFUN_VAR_INLINE_H