Переглянути джерело

refactor: 拆分runtime模块

SongZihuan 3 роки тому
батько
коміт
c9a1a4882f
36 змінених файлів з 641 додано та 453 видалено
  1. 12 3
      include/runtime/aFunrt.h
  2. 15 0
      include/runtime/rt_callback_var_object.h
  3. 5 21
      include/runtime/rt_error_message.h
  4. 4 13
      include/runtime/rt_error_message.inline.h
  5. 24 0
      include/runtime/rt_exe_activation.h
  6. 19 0
      include/runtime/rt_exe_activation.inline.h
  7. 37 0
      include/runtime/rt_func_activation.h
  8. 11 0
      include/runtime/rt_func_activation.inline.h
  9. 43 0
      include/runtime/rt_func_object.h
  10. 4 14
      include/runtime/rt_func_object.inline.h
  11. 14 0
      include/runtime/rt_literaler_object.h
  12. 8 55
      include/runtime/rt_normal_activation.h
  13. 4 24
      include/runtime/rt_normal_activation.inline.h
  14. 4 4
      include/runtime/rt_normal_activation.template.h
  15. 22 0
      include/runtime/rt_normal_message.h
  16. 15 0
      include/runtime/rt_normal_message.inline.h
  17. 0 109
      include/runtime/rt_object.h
  18. 21 0
      include/runtime/rt_top_activation.h
  19. 11 0
      include/runtime/rt_top_activation.inline.h
  20. 13 0
      include/runtime/rt_top_message.h
  21. 25 0
      include/runtime/rt_var_object.h
  22. 50 0
      include/runtime/rt_varspace_object.h
  23. 19 0
      include/runtime/rt_varspace_object.inline.h
  24. 4 4
      include/runtime/rt_varspace_object.template.h
  25. 0 0
      src/core/env_var.cpp
  26. 7 0
      src/runtime/callback_var_object.cpp
  27. 1 16
      src/runtime/error_message.cpp
  28. 28 0
      src/runtime/exe_activation.cpp
  29. 138 0
      src/runtime/func_activation.cpp
  30. 7 0
      src/runtime/func_object.cpp
  31. 10 158
      src/runtime/normal_activation.cpp
  32. 18 0
      src/runtime/normal_message.cpp
  33. 8 0
      src/runtime/top_activation.cpp
  34. 14 0
      src/runtime/top_activation.h
  35. 25 0
      src/runtime/var_object.cpp
  36. 1 32
      src/runtime/varspace_object.cpp

+ 12 - 3
include/runtime/aFunrt.h

@@ -1,10 +1,19 @@
 #ifndef AFUN_AFUNRT_H
 #define AFUN_AFUNRT_H
 
-#include "rt_activation.h"
 #include "rt_logger.h"
-#include "rt_message.h"
-#include "rt_object.h"
+#include "rt_normal_activation.h"
+#include "rt_exe_activation.h"
+#include "rt_top_activation.h"
+#include "rt_func_activation.h"
+#include "rt_top_message.h"
+#include "rt_normal_message.h"
+#include "rt_error_message.h"
+#include "rt_func_object.h"
+#include "rt_literaler_object.h"
+#include "rt_callback_var_object.h"
+#include "rt_var_object.h"
+#include "rt_varspace_object.h"
 #include "rt_exception.h"
 
 #endif //AFUN_AFUNRT_H

+ 15 - 0
include/runtime/rt_callback_var_object.h

@@ -0,0 +1,15 @@
+#ifndef AFUN_RT_CALLBACK_VAR_OBJECT_H
+#define AFUN_RT_CALLBACK_VAR_OBJECT_H
+#include <list>
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT CallBackVar : public virtual aFuncore::Object {
+    public:
+        virtual bool isCallBack(aFuncore::Inter &inter, aFuncore::Activation &activation);
+        virtual void callBack(aFuncore::Inter &inter, aFuncore::Activation &activation) = 0;
+    };
+}
+
+#endif //AFUN_RT_CALLBACK_VAR_OBJECT_H

+ 5 - 21
include/runtime/rt_message.h → include/runtime/rt_error_message.h

@@ -1,26 +1,10 @@
-#ifndef AFUN_RT_MESSAGE_H
-#define AFUN_RT_MESSAGE_H
+#ifndef AFUN_RT_ERROR_MESSAGE_H
+#define AFUN_RT_ERROR_MESSAGE_H
 #include "aFunRuntimeExport.h"
 #include "aFuncore.h"
+#include "rt_top_message.h"
 
 namespace aFunrt {
-    class TopMessage : public virtual aFuncore::Message {
-    public:
-        virtual void topProgress(aFuncore::Inter &inter, aFuncore::Activation &activation) = 0;
-    };
-
-    class AFUN_RT_EXPORT NormalMessage : public TopMessage {
-    public:
-        explicit NormalMessage(aFuncore::Object *obj_);
-        AFUN_INLINE NormalMessage(NormalMessage &&msg) noexcept;
-        ~NormalMessage() override;
-        void topProgress(aFuncore::Inter &inter, aFuncore::Activation &activation) override;
-        AFUN_INLINE aFuncore::Object *getObject();
-
-    private:
-        aFuncore::Object *obj;
-    };
-
     class AFUN_RT_EXPORT ErrorMessage : public TopMessage {
     public:
         struct TrackBack {
@@ -44,5 +28,5 @@ namespace aFunrt {
     };
 }
 
-#include "rt_message.inline.h"
-#endif //AFUN_RT_MESSAGE_H
+#include "rt_error_message.inline.h"
+#endif //AFUN_RT_ERROR_MESSAGE_H

+ 4 - 13
include/runtime/rt_message.inline.h → include/runtime/rt_error_message.inline.h

@@ -1,16 +1,8 @@
-#ifndef AFUN_RT_MESSAGE_INLINE_H
-#define AFUN_RT_MESSAGE_INLINE_H
-#include "rt_message.h"
+#ifndef AFUN_RT_ERROR_MESSAGE_INLINE_H
+#define AFUN_RT_ERROR_MESSAGE_INLINE_H
+#include "rt_error_message.h"
 
 namespace aFunrt {
-    NormalMessage::NormalMessage(NormalMessage &&msg) noexcept : obj {msg.obj}{
-        msg.obj = nullptr;
-    }
-
-    aFuncore::Object *NormalMessage::getObject() {
-        return obj;
-    }
-
     ErrorMessage::ErrorMessage(ErrorMessage &&msg) noexcept
             : inter{msg.inter}, error_type{std::move(msg.error_type)},
               error_info{std::move(msg.error_info)}, trackback{std::move(msg.trackback)}{
@@ -30,5 +22,4 @@ namespace aFunrt {
     }
 }
 
-
-#endif //AFUN_RT_MESSAGE_INLINE_H
+#endif //AFUN_RT_ERROR_MESSAGE_INLINE_H

+ 24 - 0
include/runtime/rt_exe_activation.h

@@ -0,0 +1,24 @@
+#ifndef AFUN_RT_EXE_ACTIVATION_H
+#define AFUN_RT_EXE_ACTIVATION_H
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+#include "rt_func_object.h"
+#include "rt_normal_activation.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT ExeActivation : public NormalActivation {
+    public:
+        AFUN_INLINE ExeActivation(const aFuncode::Code &code, aFuncore::Inter &inter_);
+        AFUN_INLINE ExeActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_);
+        ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) override;
+        [[nodiscard]] AFUN_INLINE const aFuncode::Code::ByteCode *getStart() const;
+
+    private:
+        const aFuncode::Code::ByteCode *start;
+        const aFuncode::Code::ByteCode *next;
+        bool first=true;
+    };
+}
+
+#include "rt_exe_activation.inline.h"
+#endif //AFUN_RT_EXE_ACTIVATION_H

+ 19 - 0
include/runtime/rt_exe_activation.inline.h

@@ -0,0 +1,19 @@
+#ifndef AFUN_RT_EXE_ACTIVATION_INLINE_H
+#define AFUN_RT_EXE_ACTIVATION_INLINE_H
+#include "rt_exe_activation.h"
+
+namespace aFunrt {
+    ExeActivation::ExeActivation(const aFuncode::Code &code, aFuncore::Inter &inter_) : NormalActivation(inter_), start{code.getByteCode()}, next{code.getByteCode()} {
+
+    }
+
+    ExeActivation::ExeActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_) : NormalActivation(inter_), start{code}, next{code} {
+
+    }
+
+    const aFuncode::Code::ByteCode *ExeActivation::getStart() const{
+        return start;
+    }
+}
+
+#endif //AFUN_RT_EXE_ACTIVATION_INLINE_H

+ 37 - 0
include/runtime/rt_func_activation.h

@@ -0,0 +1,37 @@
+#ifndef AFUN_RT_FUNC_ACTIVATION_H
+#define AFUN_RT_FUNC_ACTIVATION_H
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+#include "rt_func_object.h"
+#include "rt_normal_activation.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT FuncActivation : public NormalActivation {
+    public:
+        AFUN_INLINE explicit FuncActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_);
+        explicit FuncActivation(Function *func, aFuncore::Inter &inter_);
+        ~FuncActivation() override;
+        ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) override;
+        void endRun() override;
+
+    private:
+        enum {
+            func_first = 0,  // 获取函数体前准备
+            func_get_func = 1,  // 获取函数体后,开始获取参数前
+            func_get_arg = 2,  // 获取参数过程
+        } status = func_first;
+
+        bool on_tail = false;
+        const aFuncode::Code::ByteCode *call;
+
+        Function *func = nullptr;
+        Function::CallFunction *call_func = nullptr;
+
+        std::list<Function::CallFunction::ArgCodeList> *acl = nullptr;
+        std::list<Function::CallFunction::ArgCodeList>::iterator acl_begin;
+        std::list<Function::CallFunction::ArgCodeList>::iterator acl_end;
+    };
+}
+
+#include "rt_func_activation.inline.h"
+#endif //AFUN_RT_FUNC_ACTIVATION_H

+ 11 - 0
include/runtime/rt_func_activation.inline.h

@@ -0,0 +1,11 @@
+#ifndef AFUN_RT_FUNC_ACTIVATION_INLINE_H
+#define AFUN_RT_FUNC_ACTIVATION_INLINE_H
+#include "rt_func_activation.h"
+
+namespace aFunrt {
+    FuncActivation::FuncActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_) : NormalActivation(inter_), call{code} {
+
+    }
+}
+
+#endif //AFUN_RT_FUNC_ACTIVATION_INLINE_H

+ 43 - 0
include/runtime/rt_func_object.h

@@ -0,0 +1,43 @@
+#ifndef AFUN_RT_FUNC_OBJECT_H
+#define AFUN_RT_FUNC_OBJECT_H
+#include <list>
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT Function : public virtual aFuncore::Object {
+    public:
+        class AFUN_RT_EXPORT CallFunction;
+
+        virtual CallFunction *getCallFunction(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter) = 0;
+        virtual bool isInfix();
+    };
+
+    class AFUN_RT_EXPORT Function::CallFunction {
+    public:
+        class ArgCodeList;
+
+        CallFunction() = default;
+        virtual ~CallFunction() = default;
+        CallFunction(const CallFunction &)=delete;
+        CallFunction &operator=(const CallFunction &)=delete;
+
+        virtual std::list<ArgCodeList> *getArgCodeList(aFuncore::Inter &inter, aFuncore::Activation &activation, const aFuncode::Code::ByteCode *call) = 0;
+        virtual void runFunction() = 0;
+    };
+
+    class Function::CallFunction::ArgCodeList {
+    public:
+        const aFuncode::Code::ByteCode *code = nullptr;
+        AFUN_INLINE explicit ArgCodeList(const aFuncode::Code::ByteCode *code = nullptr);
+        AFUN_INLINE ~ArgCodeList();
+        AFUN_INLINE aFuncore::Object *setObject(aFuncore::Object *res);
+        AFUN_INLINE aFuncore::Object *getObject();
+    private:
+        aFuncore::Object *ret;
+    };
+}
+
+#include "rt_func_object.inline.h"
+
+#endif //AFUN_RT_FUNC_OBJECT_H

+ 4 - 14
include/runtime/rt_object.inline.h → include/runtime/rt_func_object.inline.h

@@ -1,18 +1,8 @@
-#ifndef AFUN_RT_OBJECT_INLINE_H
-#define AFUN_RT_OBJECT_INLINE_H
-#include "rt_object.h"
+#ifndef AFUN_RT_FUNC_OBJECT_INLINE_H
+#define AFUN_RT_FUNC_OBJECT_INLINE_H
+#include "rt_func_object.h"
 
 namespace aFunrt {
-    size_t VarSpace::getCount() {
-        std::unique_lock<std::mutex> mutex{lock};
-        return var.size();
-    }
-
-    aFuncore::Object *VarSpace::findObject(const std::string &name) {
-        Var *ret = findVar(name);
-        return ret ? ret->getData() : nullptr;
-    }
-
     Function::CallFunction::ArgCodeList::ArgCodeList(const aFuncode::Code::ByteCode *code_) : code{code_}, ret{nullptr} {
 
     }
@@ -36,4 +26,4 @@ namespace aFunrt {
 };
 
 
-#endif //AFUN_RT_OBJECT_INLINE_H
+#endif //AFUN_RT_FUNC_OBJECT_INLINE_H

+ 14 - 0
include/runtime/rt_literaler_object.h

@@ -0,0 +1,14 @@
+#ifndef AFUN_RT_LITERALER_OBJECT_H
+#define AFUN_RT_LITERALER_OBJECT_H
+#include <list>
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT Literaler : public virtual aFuncore::Object {
+    public:
+        virtual void getObject(const std::string &literal, char prefix, aFuncore::Inter &inter, aFuncore::Activation &activation) = 0;
+    };
+}
+
+#endif //AFUN_RT_LITERALER_OBJECT_H

+ 8 - 55
include/runtime/rt_activation.h → include/runtime/rt_normal_activation.h

@@ -1,8 +1,10 @@
-#ifndef AFUN_RT_ACTIVATION_H
-#define AFUN_RT_ACTIVATION_H
+#ifndef AFUN_RT_NORMAL_ACTIVATION_H
+#define AFUN_RT_NORMAL_ACTIVATION_H
 #include "aFunRuntimeExport.h"
 #include "aFuncore.h"
-#include "rt_object.h"
+#include "rt_func_object.h"
+#include "rt_varspace_object.h"
+#include "rt_var_object.h"
 
 namespace aFunrt {
     class AFUN_RT_EXPORT NormalActivation : public aFuncore::Activation {
@@ -63,58 +65,9 @@ namespace aFunrt {
         virtual void runCodeBlockC(const aFuncode::Code::ByteCode *code);
         virtual void runCodeBlockB(const aFuncode::Code::ByteCode *code);
     };
-
-    class AFUN_RT_EXPORT ExeActivation : public NormalActivation {
-    public:
-        AFUN_INLINE ExeActivation(const aFuncode::Code &code, aFuncore::Inter &inter_);
-        AFUN_INLINE ExeActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_);
-        ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) override;
-        [[nodiscard]] AFUN_INLINE const aFuncode::Code::ByteCode *getStart() const;
-
-    private:
-        const aFuncode::Code::ByteCode *start;
-        const aFuncode::Code::ByteCode *next;
-        bool first=true;
-    };
-
-    class AFUN_RT_EXPORT TopActivation : public ExeActivation {
-    public:
-        explicit TopActivation(const aFuncode::Code &code, aFuncore::Inter &inter_);
-        ~TopActivation() override = default;
-        [[nodiscard]] AFUN_INLINE const aFuncode::Code &getBase() const;
-
-    private:
-        const aFuncode::Code &base;
-    };
-
-    class AFUN_RT_EXPORT FuncActivation : public NormalActivation {
-    public:
-        AFUN_INLINE explicit FuncActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_);
-        explicit FuncActivation(Function *func, aFuncore::Inter &inter_);
-        ~FuncActivation() override;
-        ActivationStatus getCode(const aFuncode::Code::ByteCode *&code) override;
-        void endRun() override;
-
-    private:
-        enum {
-            func_first = 0,  // 获取函数体前准备
-            func_get_func = 1,  // 获取函数体后,开始获取参数前
-            func_get_arg = 2,  // 获取参数过程
-        } status = func_first;
-
-        bool on_tail = false;
-        const aFuncode::Code::ByteCode *call;
-
-        Function *func = nullptr;
-        Function::CallFunction *call_func = nullptr;
-
-        std::list<Function::CallFunction::ArgCodeList> *acl = nullptr;
-        std::list<Function::CallFunction::ArgCodeList>::iterator acl_begin;
-        std::list<Function::CallFunction::ArgCodeList>::iterator acl_end;
-    };
 }
 
-#include "rt_activation.inline.h"
-#include "rt_activation.template.h"
+#include "rt_normal_activation.inline.h"
+#include "rt_normal_activation.template.h"
 
-#endif //AFUN_RT_ACTIVATION_H
+#endif //AFUN_RT_NORMAL_ACTIVATION_H

+ 4 - 24
include/runtime/rt_activation.inline.h → include/runtime/rt_normal_activation.inline.h

@@ -1,7 +1,7 @@
-#ifndef AFUN_RT_ACTIVATION_INLINE_H
-#define AFUN_RT_ACTIVATION_INLINE_H
+#ifndef AFUN_RT_NORMAL_ACTIVATION_INLINE_H
+#define AFUN_RT_NORMAL_ACTIVATION_INLINE_H
 
-#include "rt_activation.h"
+#include "rt_normal_activation.h"
 
 namespace aFunrt {
     NormalActivation::VarList &NormalActivation::getVarlist(){
@@ -35,27 +35,7 @@ namespace aFunrt {
         Var *var = findVar(name);
         return var ? var->getData() : nullptr;
     }
-
-    ExeActivation::ExeActivation(const aFuncode::Code &code, aFuncore::Inter &inter_) : NormalActivation(inter_), start{code.getByteCode()}, next{code.getByteCode()} {
-
-    }
-
-    ExeActivation::ExeActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_) : NormalActivation(inter_), start{code}, next{code} {
-
-    }
-
-    const aFuncode::Code::ByteCode *ExeActivation::getStart() const{
-        return start;
-    }
-
-    const aFuncode::Code &TopActivation::getBase() const {
-        return base;
-    }
-
-    FuncActivation::FuncActivation(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter_) : NormalActivation(inter_), call{code} {
-
-    }
 }
 
 
-#endif //AFUN_RT_ACTIVATION_INLINE_H
+#endif //AFUN_RT_NORMAL_ACTIVATION_INLINE_H

+ 4 - 4
include/runtime/rt_activation.template.h → include/runtime/rt_normal_activation.template.h

@@ -1,6 +1,6 @@
-#ifndef AFUN_RT_ACTIVATION_TEMPLATE_H
-#define AFUN_RT_ACTIVATION_TEMPLATE_H
-#include "rt_activation.h"
+#ifndef AFUN_RT_NORMAL_ACTIVATION_TEMPLATE_H
+#define AFUN_RT_NORMAL_ACTIVATION_TEMPLATE_H
+#include "rt_normal_activation.h"
 
 namespace aFunrt {
     template <typename Callable, typename...T>
@@ -11,4 +11,4 @@ namespace aFunrt {
 }
 
 
-#endif //AFUN_RT_ACTIVATION_TEMPLATE_H
+#endif //AFUN_RT_NORMAL_ACTIVATION_TEMPLATE_H

+ 22 - 0
include/runtime/rt_normal_message.h

@@ -0,0 +1,22 @@
+#ifndef AFUN_RT_NORMAL_MESSAGE_H
+#define AFUN_RT_NORMAL_MESSAGE_H
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+#include "rt_top_message.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT NormalMessage : public TopMessage {
+    public:
+        explicit NormalMessage(aFuncore::Object *obj_);
+        AFUN_INLINE NormalMessage(NormalMessage &&msg) noexcept;
+        ~NormalMessage() override;
+        void topProgress(aFuncore::Inter &inter, aFuncore::Activation &activation) override;
+        AFUN_INLINE aFuncore::Object *getObject();
+
+    private:
+        aFuncore::Object *obj;
+    };
+}
+
+#include "rt_normal_message.inline.h"
+#endif //AFUN_RT_NORMAL_MESSAGE_H

+ 15 - 0
include/runtime/rt_normal_message.inline.h

@@ -0,0 +1,15 @@
+#ifndef AFUN_RT_NORMAL_MESSAGE_INLINE_H
+#define AFUN_RT_NORMAL_MESSAGE_INLINE_H
+#include "rt_normal_message.h"
+
+namespace aFunrt {
+    NormalMessage::NormalMessage(NormalMessage &&msg) noexcept : obj {msg.obj}{
+        msg.obj = nullptr;
+    }
+
+    aFuncore::Object *NormalMessage::getObject() {
+        return obj;
+    }
+}
+
+#endif //AFUN_RT_NORMAL_MESSAGE_INLINE_H

+ 0 - 109
include/runtime/rt_object.h

@@ -1,109 +0,0 @@
-#ifndef AFUN_RT_OBJECT_H
-#define AFUN_RT_OBJECT_H
-#include <list>
-#include <mutex>
-#include "aFunRuntimeExport.h"
-#include "aFuncore.h"
-
-namespace aFunrt {
-    class AFUN_RT_EXPORT Var : public aFuncore::Object {
-    public:
-        aFuncore::Environment &env;
-
-        Var(Object *data_, aFuncore::Inter &inter);
-        Var(Object *data_, aFuncore::Environment &env_);
-        ~Var() override = default;
-
-        [[nodiscard]] virtual Object *getData();
-        virtual void setData(Object *data_);
-        void linkObject(std::queue<Object *> &queue) override;
-
-    private:
-        Object *data;
-    };
-
-    class AFUN_RT_EXPORT VarSpace : public aFuncore::Object {
-    public:
-        typedef enum VarOperationFlat {
-            vof_success = 0,  // 成功
-            vof_not_var = 1,  // 变量不存在
-            vof_redefine_var = 2,  // 变量重复定义
-            vof_fail = 3,  // 存在其他错误
-        } VarOperationFlat;
-
-        aFuncore::Environment &env;
-
-        explicit VarSpace(aFuncore::Inter &inter);
-        explicit VarSpace(aFuncore::Environment &env_);
-        ~VarSpace() override = default;
-
-        template <typename Callable,typename...T>
-        void forEach(Callable func, T...arg);
-
-        template <typename Callable,typename...T>
-        void forEachLock(Callable func, T...arg);
-
-        [[nodiscard]] AFUN_INLINE size_t getCount();
-        [[nodiscard]] virtual Var *findVar(const std::string &name);
-        virtual VarOperationFlat defineVar(const std::string &name, aFuncore::Object *data);
-        virtual VarOperationFlat defineVar(const std::string &name, Var *data);
-        virtual VarOperationFlat setVar(const std::string &name, aFuncore::Object *data);
-        virtual VarOperationFlat delVar(const std::string &name);
-
-        [[nodiscard]] AFUN_INLINE aFuncore::Object *findObject(const std::string &name);
-        void linkObject(std::queue<aFuncore::Object *> &queue) override;
-
-        AFUN_STATIC const size_t VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
-
-    private:
-        std::unordered_map<std::string, Var *> var;
-    };
-
-    class AFUN_RT_EXPORT Function : public virtual aFuncore::Object {
-    public:
-        class AFUN_RT_EXPORT CallFunction;
-
-        virtual CallFunction *getCallFunction(const aFuncode::Code::ByteCode *code, aFuncore::Inter &inter) = 0;
-        virtual bool isInfix();
-    };
-
-    class AFUN_RT_EXPORT Function::CallFunction {
-    public:
-        class ArgCodeList;
-
-        CallFunction() = default;
-        virtual ~CallFunction() = default;
-        CallFunction(const CallFunction &)=delete;
-        CallFunction &operator=(const CallFunction &)=delete;
-
-        virtual std::list<ArgCodeList> *getArgCodeList(aFuncore::Inter &inter, aFuncore::Activation &activation, const aFuncode::Code::ByteCode *call) = 0;
-        virtual void runFunction() = 0;
-    };
-
-    class Function::CallFunction::ArgCodeList {
-    public:
-        const aFuncode::Code::ByteCode *code = nullptr;
-        AFUN_INLINE explicit ArgCodeList(const aFuncode::Code::ByteCode *code = nullptr);
-        AFUN_INLINE ~ArgCodeList();
-        AFUN_INLINE aFuncore::Object *setObject(aFuncore::Object *res);
-        AFUN_INLINE aFuncore::Object *getObject();
-    private:
-        aFuncore::Object *ret;
-    };
-
-    class AFUN_RT_EXPORT Literaler : public virtual aFuncore::Object {
-    public:
-        virtual void getObject(const std::string &literal, char prefix, aFuncore::Inter &inter, aFuncore::Activation &activation) = 0;
-    };
-
-    class AFUN_RT_EXPORT CallBackVar : public virtual aFuncore::Object {
-    public:
-        virtual bool isCallBack(aFuncore::Inter &inter, aFuncore::Activation &activation);
-        virtual void callBack(aFuncore::Inter &inter, aFuncore::Activation &activation) = 0;
-    };
-};
-
-#include "rt_object.inline.h"
-#include "rt_object.template.h"
-
-#endif //AFUN_RT_OBJECT_H

+ 21 - 0
include/runtime/rt_top_activation.h

@@ -0,0 +1,21 @@
+#ifndef AFUN_RT_TOP_ACTIVATION_H
+#define AFUN_RT_TOP_ACTIVATION_H
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+#include "rt_func_object.h"
+#include "rt_exe_activation.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT TopActivation : public ExeActivation {
+    public:
+        explicit TopActivation(const aFuncode::Code &code, aFuncore::Inter &inter_);
+        ~TopActivation() override = default;
+        [[nodiscard]] AFUN_INLINE const aFuncode::Code &getBase() const;
+
+    private:
+        const aFuncode::Code &base;
+    };
+}
+
+#include "rt_top_activation.inline.h"
+#endif //AFUN_RT_TOP_ACTIVATION_H

+ 11 - 0
include/runtime/rt_top_activation.inline.h

@@ -0,0 +1,11 @@
+#ifndef AFUN_RT_TOP_ACTIVATION_INLINE_H
+#define AFUN_RT_TOP_ACTIVATION_INLINE_H
+#include "rt_top_activation.h"
+
+namespace aFunrt {
+    const aFuncode::Code &TopActivation::getBase() const {
+        return base;
+    }
+}
+
+#endif //AFUN_RT_TOP_ACTIVATION_INLINE_H

+ 13 - 0
include/runtime/rt_top_message.h

@@ -0,0 +1,13 @@
+#ifndef AFUN_RT_TOP_MESSAGE_H
+#define AFUN_RT_TOP_MESSAGE_H
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+
+namespace aFunrt {
+    class TopMessage : public virtual aFuncore::Message {
+    public:
+        virtual void topProgress(aFuncore::Inter &inter, aFuncore::Activation &activation) = 0;
+    };
+}
+
+#endif //AFUN_RT_TOP_MESSAGE_H

+ 25 - 0
include/runtime/rt_var_object.h

@@ -0,0 +1,25 @@
+#ifndef AFUN_VAR_OBJECT_H
+#define AFUN_VAR_OBJECT_H
+#include <list>
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT Var : public aFuncore::Object {
+    public:
+        aFuncore::Environment &env;
+
+        Var(Object *data_, aFuncore::Inter &inter);
+        Var(Object *data_, aFuncore::Environment &env_);
+        ~Var() override = default;
+
+        [[nodiscard]] virtual Object *getData();
+        virtual void setData(Object *data_);
+        void linkObject(std::queue<Object *> &queue) override;
+
+    private:
+        Object *data;
+    };
+}
+
+#endif //AFUN_VAR_OBJECT_H

+ 50 - 0
include/runtime/rt_varspace_object.h

@@ -0,0 +1,50 @@
+#ifndef AFUN_VARSPACE_OBJECT_H
+#define AFUN_VARSPACE_OBJECT_H
+#include <list>
+#include "aFunRuntimeExport.h"
+#include "aFuncore.h"
+#include "rt_var_object.h"
+
+namespace aFunrt {
+    class AFUN_RT_EXPORT VarSpace : public aFuncore::Object {
+    public:
+        typedef enum VarOperationFlat {
+            vof_success = 0,  // 成功
+            vof_not_var = 1,  // 变量不存在
+            vof_redefine_var = 2,  // 变量重复定义
+            vof_fail = 3,  // 存在其他错误
+        } VarOperationFlat;
+
+        aFuncore::Environment &env;
+
+        explicit VarSpace(aFuncore::Inter &inter);
+        explicit VarSpace(aFuncore::Environment &env_);
+        ~VarSpace() override = default;
+
+        template <typename Callable,typename...T>
+        void forEach(Callable func, T...arg);
+
+        template <typename Callable,typename...T>
+        void forEachLock(Callable func, T...arg);
+
+        [[nodiscard]] AFUN_INLINE size_t getCount();
+        [[nodiscard]] virtual Var *findVar(const std::string &name);
+        virtual VarOperationFlat defineVar(const std::string &name, aFuncore::Object *data);
+        virtual VarOperationFlat defineVar(const std::string &name, Var *data);
+        virtual VarOperationFlat setVar(const std::string &name, aFuncore::Object *data);
+        virtual VarOperationFlat delVar(const std::string &name);
+
+        [[nodiscard]] AFUN_INLINE aFuncore::Object *findObject(const std::string &name);
+        void linkObject(std::queue<aFuncore::Object *> &queue) override;
+
+        AFUN_STATIC const size_t VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
+
+    private:
+        std::unordered_map<std::string, Var *> var;
+    };
+}
+
+#include "rt_varspace_object.inline.h"
+#include "rt_varspace_object.template.h"
+
+#endif //AFUN_VARSPACE_OBJECT_H

+ 19 - 0
include/runtime/rt_varspace_object.inline.h

@@ -0,0 +1,19 @@
+#ifndef AFUN_RT_VARSPACE_OBJECT_INLINE_H
+#define AFUN_RT_VARSPACE_OBJECT_INLINE_H
+
+#include "rt_varspace_object.h"
+
+namespace aFunrt {
+    size_t VarSpace::getCount() {
+        std::unique_lock<std::mutex> mutex{lock};
+        return var.size();
+    }
+
+    aFuncore::Object *VarSpace::findObject(const std::string &name) {
+        Var *ret = findVar(name);
+        return ret ? ret->getData() : nullptr;
+    }
+}
+
+
+#endif //AFUN_RT_VARSPACE_OBJECT_INLINE_H

+ 4 - 4
include/runtime/rt_object.template.h → include/runtime/rt_varspace_object.template.h

@@ -1,7 +1,7 @@
-#ifndef AFUN_RT_OBJECT_TEMPLATE_H
-#define AFUN_RT_OBJECT_TEMPLATE_H
+#ifndef AFUN_RT_VARSPACE_OBJECT_TEMPLATE_H
+#define AFUN_RT_VARSPACE_OBJECT_TEMPLATE_H
 
-#include "rt_object.h"
+#include "rt_varspace_object.h"
 
 namespace aFunrt {
     template <typename Callable, typename...T>
@@ -22,4 +22,4 @@ namespace aFunrt {
     }
 }
 
-#endif //AFUN_RT_OBJECT_TEMPLATE_H
+#endif //AFUN_RT_VARSPACE_OBJECT_TEMPLATE_H

+ 0 - 0
src/core/env-var.cpp → src/core/env_var.cpp


+ 7 - 0
src/runtime/callback_var_object.cpp

@@ -0,0 +1,7 @@
+#include "rt_callback_var_object.h"
+
+namespace aFunrt {
+    bool CallBackVar::isCallBack(aFuncore::Inter &, aFuncore::Activation &) {
+        return true;
+    }
+}

+ 1 - 16
src/runtime/message.cpp → src/runtime/error_message.cpp

@@ -1,21 +1,6 @@
-#include "rt_message.h"
+#include "rt_error_message.h"
 
 namespace aFunrt {
-    NormalMessage::NormalMessage(aFuncore::Object *obj_) : obj {obj_} {
-        obj->addReference();
-    }
-
-    NormalMessage::~NormalMessage(){
-        if (obj != nullptr) {
-            obj->delReference();
-            obj = nullptr;
-        }
-    }
-
-    void NormalMessage::topProgress(aFuncore::Inter &inter, aFuncore::Activation &){
-        inter.getOutMessageStream().pushMessage("NORMAL", new NormalMessage(std::move(*this)));
-    }
-
     ErrorMessage::ErrorMessage(std::string error_type_, std::string error_info_, aFuncore::Inter &inter)
             : inter{inter}, error_type{std::move(error_type_)}, error_info{std::move(error_info_)} {
         for (const auto activation : inter.getStack()) {

+ 28 - 0
src/runtime/exe_activation.cpp

@@ -0,0 +1,28 @@
+#include "rt_exe_activation.h"
+#include "rt_exception.h"
+#include "rt_normal_message.h"
+#include "rt_error_message.h"
+#include "rt_logger.h"
+
+namespace aFunrt {
+    NormalActivation::ActivationStatus ExeActivation::getCode(const aFuncode::Code::ByteCode *&code){
+        code = next;
+        if (code == nullptr)
+            return as_end;
+
+        if (!first) {
+            auto msg = down.getMessage<NormalMessage>("NORMAL");
+            if (msg == nullptr)
+                return as_end;
+            else
+                down.popMessage("NORMAL");
+            delete msg;
+        }
+
+        first = false;
+        line = code->getFileLine();
+        path = code->getFilePath();
+        next = code->toNext();
+        return as_run;
+    }
+}

+ 138 - 0
src/runtime/func_activation.cpp

@@ -0,0 +1,138 @@
+#include "rt_func_activation.h"
+#include "rt_exception.h"
+#include "rt_normal_message.h"
+#include "rt_error_message.h"
+#include "rt_logger.h"
+
+namespace aFunrt {
+    FuncActivation::FuncActivation(Function *func_, aFuncore::Inter &inter_)
+            : NormalActivation(inter_), status{func_get_func}, on_tail{false}, call{nullptr}, func{func_}, acl_begin{}, acl_end{}  {
+        func->addReference();
+    }
+
+    FuncActivation::~FuncActivation(){
+        if (func != nullptr)
+            func->delReference();
+        delete call_func;
+    }
+
+    NormalActivation::ActivationStatus FuncActivation::getCode(const aFuncode::Code::ByteCode *&code) {
+        if (on_tail)
+            return as_end;
+
+        if (status == func_first) {
+            switch (call->getBlockType()) {
+                case aFuncode::Code::ByteCode::block_c:
+                    status = func_get_func;
+                    code = call->getSon();
+                    if (code == nullptr) {
+                        line = 0;
+                        down.pushMessage("ERROR", new ErrorMessage("SyntaxError", "Callback without code.",
+                                                                   inter));
+                        return as_end;
+                    }
+                    line = code->getFileLine();
+                    if (!code->getFilePath().empty())
+                        path = code->getFilePath();
+                    return as_run;
+                case aFuncode::Code::ByteCode::block_b: {
+                    std::string prefix;
+                    if (!inter.getEnvVarSpace().findString("sys:prefix-quote", prefix) || prefix.size() != 1)
+                        prefix = "'";
+                    char quote = prefix[0];
+                    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()))
+                            continue;
+                        aFuncore::Object *obj = varlist.findObject(var->getElement());
+                        if (obj == nullptr)
+                            inter.getEnvVarSpace().findObject(var->getElement(), obj);
+                        if (obj == nullptr || !dynamic_cast<Function *>(obj) ||
+                            !dynamic_cast<Function *>(obj)->isInfix())
+                            continue;
+                        func = dynamic_cast<Function *>(obj);
+                        if (func == nullptr || !func->isInfix())
+                            continue;
+                        func->addReference();
+                        status = func_get_func;
+                        break;  /* 跳转到: 执行变量获取前的准备 */
+                    }
+                    if (status != func_get_func) {
+                        line = 0;
+                        down.pushMessage("ERROR", new ErrorMessage("SyntaxError", "Callback without code.",
+                                                                   inter));
+                        return as_end;
+                    }
+                    break;
+                }
+                default:
+                    errorLog(aFunRuntimeLogger, "Error FuncActivation block type");
+                    line = 0;
+                    down.pushMessage("ERROR", new ErrorMessage("RuntimeError", "Error FuncActivation block type.",
+                                                               inter));
+                    return as_end;
+            }
+        }
+
+        if (status == func_get_func) {
+            if (func == nullptr) {
+                auto *msg = down.getMessage<NormalMessage>("NORMAL");
+                if (msg == nullptr)
+                    return as_end;
+                else
+                    down.popMessage("NORMAL");
+                func = dynamic_cast<Function *>(msg->getObject());
+                delete msg;
+                if (func == nullptr) {
+                    down.pushMessage("ERROR", new ErrorMessage("TypeError", "Callback without function.", inter));
+                    return as_end;
+                }
+                func->addReference();
+            }
+
+            /* Label: 执行变量获取前的准备 */
+            status = func_get_arg;
+            try {
+                call_func = func->getCallFunction(call, inter);
+                acl = call_func->getArgCodeList(inter, *this, call);
+            } catch (RuntimeError &e) {
+                down.pushMessage("ERROR", new ErrorMessage(e.getType(), e.getMessage(), inter));
+                return as_end;
+            }
+            acl_begin = acl->begin();
+            acl_end = acl->end();
+            if (acl_begin != acl_end) {  // 如果有参数需要计算
+                code = acl_begin->code;
+                line = code->getFileLine();
+                path = code->getFilePath();
+                return as_run;
+            }
+        }
+
+        if (acl_begin != acl_end) {  // 获取参数计算结果
+            auto *msg = down.getMessage<NormalMessage>("NORMAL");
+            if (msg == nullptr)
+                return as_end;
+            down.popMessage("NORMAL");
+
+            acl_begin->setObject(msg->getObject());
+            delete msg;
+
+            acl_begin++;
+            if (acl_begin != acl_end) {
+                code = acl_begin->code;
+                line = code->getFileLine();
+                path = code->getFilePath();
+                return as_run;
+            }
+        }
+
+        on_tail = true;
+        line = 0;
+        return as_end_run;
+    }
+
+    void FuncActivation::endRun(){
+        call_func->runFunction();
+    }
+}

+ 7 - 0
src/runtime/func_object.cpp

@@ -0,0 +1,7 @@
+#include "rt_func_object.h"
+
+namespace aFunrt {
+    bool Function::isInfix() {
+        return false;
+    }
+}

+ 10 - 158
src/runtime/activation.cpp → src/runtime/normal_activation.cpp

@@ -1,7 +1,15 @@
-#include "rt_activation.h"
+#include "rt_normal_activation.h"
+#include "rt_exe_activation.h"
+#include "rt_func_activation.h"
 #include "rt_exception.h"
-#include "rt_message.h"
+#include "rt_normal_message.h"
+#include "rt_error_message.h"
 #include "rt_logger.h"
+#include "rt_var_object.h"
+#include "rt_varspace_object.h"
+#include "rt_func_object.h"
+#include "rt_literaler_object.h"
+#include "rt_callback_var_object.h"
 
 namespace aFunrt {
     /**
@@ -229,160 +237,4 @@ namespace aFunrt {
             this->varspace.push_back(t);
         }
     }
-
-    NormalActivation::ActivationStatus ExeActivation::getCode(const aFuncode::Code::ByteCode *&code){
-        code = next;
-        if (code == nullptr)
-            return as_end;
-
-        if (!first) {
-            auto msg = down.getMessage<NormalMessage>("NORMAL");
-            if (msg == nullptr)
-                return as_end;
-            else
-                down.popMessage("NORMAL");
-            delete msg;
-        }
-
-        first = false;
-        line = code->getFileLine();
-        path = code->getFilePath();
-        next = code->toNext();
-        return as_run;
-    }
-
-    TopActivation::TopActivation(const aFuncode::Code &code, aFuncore::Inter &inter_) : ExeActivation(code, inter_), base{code} {
-
-    }
-
-    FuncActivation::FuncActivation(Function *func_, aFuncore::Inter &inter_)
-            : NormalActivation(inter_), status{func_get_func}, on_tail{false}, call{nullptr}, func{func_}, acl_begin{}, acl_end{}  {
-        func->addReference();
-    }
-
-    FuncActivation::~FuncActivation(){
-        if (func != nullptr)
-            func->delReference();
-        delete call_func;
-    }
-
-    NormalActivation::ActivationStatus FuncActivation::getCode(const aFuncode::Code::ByteCode *&code) {
-        if (on_tail)
-            return as_end;
-
-        if (status == func_first) {
-            switch (call->getBlockType()) {
-                case aFuncode::Code::ByteCode::block_c:
-                    status = func_get_func;
-                    code = call->getSon();
-                    if (code == nullptr) {
-                        line = 0;
-                        down.pushMessage("ERROR", new ErrorMessage("SyntaxError", "Callback without code.",
-                                                                   inter));
-                        return as_end;
-                    }
-                    line = code->getFileLine();
-                    if (!code->getFilePath().empty())
-                        path = code->getFilePath();
-                    return as_run;
-                case aFuncode::Code::ByteCode::block_b: {
-                    std::string prefix;
-                    if (!inter.getEnvVarSpace().findString("sys:prefix-quote", prefix) || prefix.size() != 1)
-                        prefix = "'";
-                    char quote = prefix[0];
-                    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()))
-                            continue;
-                        aFuncore::Object *obj = varlist.findObject(var->getElement());
-                        if (obj == nullptr)
-                            inter.getEnvVarSpace().findObject(var->getElement(), obj);
-                        if (obj == nullptr || !dynamic_cast<Function *>(obj) ||
-                            !dynamic_cast<Function *>(obj)->isInfix())
-                            continue;
-                        func = dynamic_cast<Function *>(obj);
-                        if (func == nullptr || !func->isInfix())
-                            continue;
-                        func->addReference();
-                        status = func_get_func;
-                        break;  /* 跳转到: 执行变量获取前的准备 */
-                    }
-                    if (status != func_get_func) {
-                        line = 0;
-                        down.pushMessage("ERROR", new ErrorMessage("SyntaxError", "Callback without code.",
-                                                                   inter));
-                        return as_end;
-                    }
-                    break;
-                }
-                default:
-                    errorLog(aFunRuntimeLogger, "Error FuncActivation block type");
-                    line = 0;
-                    down.pushMessage("ERROR", new ErrorMessage("RuntimeError", "Error FuncActivation block type.",
-                                                               inter));
-                    return as_end;
-            }
-        }
-
-        if (status == func_get_func) {
-            if (func == nullptr) {
-                auto *msg = down.getMessage<NormalMessage>("NORMAL");
-                if (msg == nullptr)
-                    return as_end;
-                else
-                    down.popMessage("NORMAL");
-                func = dynamic_cast<Function *>(msg->getObject());
-                delete msg;
-                if (func == nullptr) {
-                    down.pushMessage("ERROR", new ErrorMessage("TypeError", "Callback without function.", inter));
-                    return as_end;
-                }
-                func->addReference();
-            }
-
-            /* Label: 执行变量获取前的准备 */
-            status = func_get_arg;
-            try {
-                call_func = func->getCallFunction(call, inter);
-                acl = call_func->getArgCodeList(inter, *this, call);
-            } catch (RuntimeError &e) {
-                down.pushMessage("ERROR", new ErrorMessage(e.getType(), e.getMessage(), inter));
-                return as_end;
-            }
-            acl_begin = acl->begin();
-            acl_end = acl->end();
-            if (acl_begin != acl_end) {  // 如果有参数需要计算
-                code = acl_begin->code;
-                line = code->getFileLine();
-                path = code->getFilePath();
-                return as_run;
-            }
-        }
-
-        if (acl_begin != acl_end) {  // 获取参数计算结果
-            auto *msg = down.getMessage<NormalMessage>("NORMAL");
-            if (msg == nullptr)
-                return as_end;
-            down.popMessage("NORMAL");
-
-            acl_begin->setObject(msg->getObject());
-            delete msg;
-
-            acl_begin++;
-            if (acl_begin != acl_end) {
-                code = acl_begin->code;
-                line = code->getFileLine();
-                path = code->getFilePath();
-                return as_run;
-            }
-        }
-
-        on_tail = true;
-        line = 0;
-        return as_end_run;
-    }
-
-    void FuncActivation::endRun(){
-        call_func->runFunction();
-    }
 }

+ 18 - 0
src/runtime/normal_message.cpp

@@ -0,0 +1,18 @@
+#include "rt_normal_message.h"
+
+namespace aFunrt {
+    NormalMessage::NormalMessage(aFuncore::Object *obj_) : obj {obj_} {
+        obj->addReference();
+    }
+
+    NormalMessage::~NormalMessage(){
+        if (obj != nullptr) {
+            obj->delReference();
+            obj = nullptr;
+        }
+    }
+
+    void NormalMessage::topProgress(aFuncore::Inter &inter, aFuncore::Activation &){
+        inter.getOutMessageStream().pushMessage("NORMAL", new NormalMessage(std::move(*this)));
+    }
+}

+ 8 - 0
src/runtime/top_activation.cpp

@@ -0,0 +1,8 @@
+#include "rt_top_activation.h"
+#include "rt_normal_message.h"
+
+namespace aFunrt {
+    TopActivation::TopActivation(const aFuncode::Code &code, aFuncore::Inter &inter_) : ExeActivation(code, inter_), base{code} {
+
+    }
+}

+ 14 - 0
src/runtime/top_activation.h

@@ -0,0 +1,14 @@
+//
+// Created by jimso on 2022/2/13.
+//
+
+#ifndef AFUN_TOP_ACTIVATION_H
+#define AFUN_TOP_ACTIVATION_H
+
+
+class top_activation {
+
+};
+
+
+#endif //AFUN_TOP_ACTIVATION_H

+ 25 - 0
src/runtime/var_object.cpp

@@ -0,0 +1,25 @@
+#include "rt_var_object.h"
+
+namespace aFunrt {
+    Var::Var(Object *data_, aFuncore::Inter &inter) : Object("Var", inter), env{inter.getEnvironment()}, data{data_}{
+
+    }
+
+    Var::Var(Object *data_, aFuncore::Environment &env_) : Object("Var", env_), env{env_}, data{data_}{
+
+    }
+
+    void Var::linkObject(std::queue<aFuncore::Object *> &queue) {
+        queue.push(getData());
+    }
+
+    aFuncore::Object *Var::getData() {
+        std::unique_lock<std::mutex> mutex{lock};
+        return data;
+    }
+
+    void Var::setData(Object *data_) {
+        std::unique_lock<std::mutex> mutex{lock};
+        data = data_;
+    }
+}

+ 1 - 32
src/runtime/object.cpp → src/runtime/varspace_object.cpp

@@ -1,15 +1,6 @@
-#include "rt_object.h"
+#include "rt_varspace_object.h"
 
 namespace aFunrt {
-    Var::Var(Object *data_, aFuncore::Inter &inter) : Object("Var", inter), env{inter.getEnvironment()}, data{data_}{
-
-    }
-
-    Var::Var(Object *data_, aFuncore::Environment &env_) : Object("Var", env_), env{env_}, data{data_}{
-
-    }
-
-
     VarSpace::VarSpace(aFuncore::Inter &inter) : Object("VarSpace", inter), env{inter.getEnvironment()}{
 
     }
@@ -18,20 +9,6 @@ namespace aFunrt {
 
     }
 
-    void Var::linkObject(std::queue<Object *> &queue) {
-        queue.push(getData());
-    }
-
-    aFuncore::Object *Var::getData() {
-        std::unique_lock<std::mutex> mutex{lock};
-        return data;
-    }
-
-    void Var::setData(Object *data_) {
-        std::unique_lock<std::mutex> mutex{lock};
-        data = data_;
-    }
-
     /**
      * 访问指定变量
      * @param name 变量名
@@ -108,12 +85,4 @@ namespace aFunrt {
         for (auto tmp : var)
             queue.push(tmp.second);
     }
-
-    bool Function::isInfix() {
-        return false;
-    }
-
-    bool CallBackVar::isCallBack(aFuncore::Inter &, aFuncore::Activation &) {
-        return true;
-    }
 }