Răsfoiți Sursa

refactor: 调整程序结构

SongZihuan 3 ani în urmă
părinte
comite
928f08a697

+ 13 - 5
include/core/activation.h

@@ -2,13 +2,21 @@
 #define AFUN_ACTIVATION_H
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.h"
 #include "value.h"
+#include "var.h"
 #include "msg.h"
 
 namespace aFuncore {
+    class Inter;
+
     class AFUN_CORE_EXPORT Activation {
     public:
+        typedef enum ActivationStatus {
+            as_run = 0,
+            as_end = 1,
+            as_end_run = 2,
+        } ActivationStatus;
+
         Inter &inter;
 
         template <typename Callable,typename...T>
@@ -27,8 +35,8 @@ namespace aFuncore {
         [[nodiscard]] inline UpMessage &getUpStream();
         [[nodiscard]] inline DownMessage &getDownStream();
 
-        [[nodiscard]] inline FileLine getFileLine() const;
-        [[nodiscard]] inline  const StringFilePath &getFilePath() const;
+        [[nodiscard]] inline aFuntool::FileLine getFileLine() const;
+        [[nodiscard]] inline  const aFuntool::StringFilePath &getFilePath() const;
 
     protected:
         Activation *prev;
@@ -38,8 +46,8 @@ namespace aFuncore {
         UpMessage up;
         DownMessage down;
 
-        StringFilePath path;
-        FileLine line;
+        aFuntool::StringFilePath path;
+        aFuntool::FileLine line;
 
         virtual void runCodeElement(Code *code);
         virtual void runCodeBlockP(Code *code);

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

@@ -24,11 +24,11 @@ namespace aFuncore {
         return down;
     }
 
-    inline FileLine Activation::getFileLine() const{
+    inline aFuntool::FileLine Activation::getFileLine() const{
         return line;
     }
 
-    inline const StringFilePath &Activation::getFilePath() const{
+    inline const aFuntool::StringFilePath &Activation::getFilePath() const{
         return path;
     }
 

+ 41 - 28
include/core/code.h

@@ -2,42 +2,30 @@
 #define AFUN_CODE_H
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.h"
 
 namespace aFuncore {
     class AFUN_CORE_EXPORT Code {
-        CodeType type;
-        char prefix=NUL;
-
-        union {
-            char *element = nullptr;  // union 内不使用 std::string
-            struct {  // NOLINT 不需要初始化
-                BlockType block_type;
-                Code *son;
-            };
-        };
-
-        Code *father = nullptr;;
-        Code *next = nullptr;;
-        Code *prev = nullptr;;
+    public:
+        typedef enum CodeType {
+            code_start = 0,
+            code_element = 1,
+            code_block = 2,
+        } CodeType;
 
-        aFuntool::FileLine line;
-        aFuntool::FilePath file;
+        typedef enum BlockType {
+            block_p = '(',
+            block_b = '[',
+            block_c = '{',
+        } BlockType;
 
-    protected:
-        explicit Code(FileLine line, ConstFilePath file="");
-        Code(const std::string &element, aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
-        Code(BlockType block_type, Code *son, aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
-        ~Code();
-    public:
         Code(const Code &)=delete;
         Code &operator=(const Code &)=delete;
 
-        static Code *create(FileLine line, ConstFilePath file="");
+        static Code *create(aFuntool::FileLine line, aFuntool::ConstFilePath file="");
         static Code *create(const std::string &element,
-                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
+                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=aFuntool::NUL);
         static Code *create(BlockType block_type, Code *son,
-                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
+                            aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=aFuntool::NUL);
         static void destruct(Code *code);
 
         Code *connect(Code *code);
@@ -49,8 +37,8 @@ namespace aFuncore {
         bool readAll_v1(FILE *f, bool debug=false);
         [[nodiscard]] std::string getMD5_v1() const;
         [[nodiscard]] std::string getMD5All_v1() const;
-        bool writeByteCode(ConstFilePath file_path, bool debug=false) const;  // NOLINT 允许忽略返回值
-        bool readByteCode(ConstFilePath file_path);
+        bool writeByteCode(aFuntool::ConstFilePath file_path, bool debug=false) const;  // NOLINT 允许忽略返回值
+        bool readByteCode(aFuntool::ConstFilePath file_path);
 
         [[nodiscard]] CodeType getType() const;
         [[nodiscard]] char getPrefix() const;
@@ -65,6 +53,31 @@ namespace aFuncore {
 
         [[nodiscard]] aFuntool::FileLine getFileLine() const;
         [[nodiscard]] aFuntool::FilePath getFilePath() const;
+
+    protected:
+        explicit Code(aFuntool::FileLine line, aFuntool::ConstFilePath file="");
+        Code(const std::string &element, aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=aFuntool::NUL);
+        Code(BlockType block_type, Code *son, aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=aFuntool::NUL);
+        ~Code();
+
+    private:
+        CodeType type;
+        char prefix=aFuntool::NUL;
+
+        union {
+            char *element = nullptr;  // union 内不使用 std::string
+            struct {  // NOLINT 不需要初始化
+                BlockType block_type;
+                Code *son;
+            };
+        };
+
+        Code *father = nullptr;;
+        Code *next = nullptr;;
+        Code *prev = nullptr;;
+
+        aFuntool::FileLine line;
+        aFuntool::FilePath file;
     };
 }
 

+ 3 - 3
include/core/code.inline.h

@@ -3,7 +3,7 @@
 #include "code.h"
 
 namespace aFuncore {
-    inline Code *Code::create(FileLine line, ConstFilePath file) {
+    inline Code *Code::create(aFuntool::FileLine line, aFuntool::ConstFilePath file) {
         return new Code(line, file);
     }
 
@@ -17,7 +17,7 @@ namespace aFuncore {
         return new Code(block_type, son, line, file);
     }
 
-    inline CodeType Code::getType() const {
+    inline Code::CodeType Code::getType() const {
         return type;
     }
 
@@ -31,7 +31,7 @@ namespace aFuncore {
         return element;
     }
 
-    inline BlockType Code::getBlockType() const {
+    inline Code::BlockType Code::getBlockType() const {
         if (type != code_block)
             return block_p;
         return block_type;

+ 0 - 79
include/core/core.h

@@ -1,87 +1,8 @@
 #ifndef AFUN_CORE_H
 #define AFUN_CORE_H
-#include "aFuntool.h"
 
 namespace aFuncore {
-    using namespace aFuntool;
 
-    typedef enum CodeType {
-        code_start = 0,
-        code_element = 1,
-        code_block = 2,
-    } CodeType;
-    typedef enum BlockType {
-        block_p = '(',
-        block_b = '[',
-        block_c = '{',
-    } BlockType;
-    class AFUN_CORE_EXPORT Code;
-
-    class AFUN_CORE_EXPORT EnvVarSpace;
-
-    class AFUN_CORE_EXPORT Inter;
-    enum InterStatus {
-        inter_creat = 0,
-        inter_init = 1,  // 执行初始化程序
-        inter_normal = 2,  // 正常执行
-        inter_stop = 3,  // 当前运算退出
-        inter_exit = 4,  // 解释器退出
-    };
-    typedef enum InterStatus InterStatus;
-    typedef enum ExitFlat {
-        ef_activity = 0,  // 主动退出
-        ef_passive = 1,  // 被动退出
-        ef_none = 2,
-    } ExitFlat;
-    typedef enum ExitMode {
-        em_activity = ef_activity,  // 主动退出
-        em_passive = ef_passive,  // 被动退出
-    } ExitMode;
-
-    static const int PREFIX_COUNT = 2;
-    typedef enum Prefix {
-        prefix_quote = 0,  // 变量引用
-        prefix_exec_first = 1,
-    } Prefix;
-    static const std::string E_PREFIX = "$`'";  /* NOLINT element前缀 */
-    static const std::string B_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
-
-    class AFUN_CORE_EXPORT Message;
-    class AFUN_CORE_EXPORT NormalMessage;
-    class AFUN_CORE_EXPORT ErrorMessage;
-
-    class AFUN_CORE_EXPORT MessageStream;
-    class AFUN_CORE_EXPORT UpMessage;
-    class AFUN_CORE_EXPORT DownMessage;
-    class AFUN_CORE_EXPORT InterMessage;
-
-    class AFUN_CORE_EXPORT Activation;
-    class AFUN_CORE_EXPORT ExeActivation;
-    class AFUN_CORE_EXPORT TopActivation;
-    class AFUN_CORE_EXPORT FuncActivation;
-    typedef enum ActivationStatus {
-        as_run = 0,
-        as_end = 1,
-        as_end_run = 2,
-    } ActivationStatus;
-
-    class AFUN_CORE_EXPORT GcList;
-
-    class AFUN_CORE_EXPORT Object;
-    class AFUN_CORE_EXPORT Function;
-    class AFUN_CORE_EXPORT Literaler;
-    class AFUN_CORE_EXPORT CallBackVar;
-
-    class AFUN_CORE_EXPORT Var;
-    class AFUN_CORE_EXPORT VarSpace;
-    class AFUN_CORE_EXPORT VarList;
-    class AFUN_CORE_EXPORT ProtectVarSpace;
-    typedef enum VarOperationFlat {
-        vof_success = 0,  // 成功
-        vof_not_var = 1,  // 变量不存在
-        vof_redefine_var = 2,  // 变量重复定义
-        vof_fail = 3,  // 存在其他错误
-    } VarOperationFlat;
 }
 
 #endif //AFUN_CORE_H

+ 33 - 2
include/core/inter.h

@@ -3,15 +3,46 @@
 #include <list>
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.h"
+
+#include "code.h"
+#include "env-var.h"
 
 #include "value.h"
 #include "var.h"
 #include "activation.h"
 
+
 namespace aFuncore {
     class AFUN_CORE_EXPORT Inter {
     public:
+        typedef enum InterStatus {
+            inter_creat = 0,
+            inter_init = 1,  // 执行初始化程序
+            inter_normal = 2,  // 正常执行
+            inter_stop = 3,  // 当前运算退出
+            inter_exit = 4,  // 解释器退出
+        } InterStatus;
+
+        typedef enum ExitFlat {
+            ef_activity = 0,  // 主动退出
+            ef_passive = 1,  // 被动退出
+            ef_none = 2,
+        } ExitFlat;
+
+        typedef enum ExitMode {
+            em_activity = ef_activity,  // 主动退出
+            em_passive = ef_passive,  // 被动退出
+        } ExitMode;
+
+        typedef enum Prefix {
+            prefix_quote = 0,  // 变量引用
+            prefix_exec_first = 1,
+        } Prefix;
+
+        static const int PREFIX_COUNT = 2;
+        constexpr static const char *E_PREFIX = "$`'";  /* NOLINT element前缀 */
+        constexpr static const char *B_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
+
         explicit Inter(int argc=0, char **argv=nullptr, ExitMode em=em_activity);
         Inter(const Inter &base_inter, ExitMode em=em_activity);
         ~Inter();
@@ -84,7 +115,7 @@ namespace aFuncore {
     };
 
     struct Inter::LiteralRegex {
-        Regex rg;
+        aFuntool::Regex rg;
         std::string pattern;  // 派生 LiteralRegex 时使用
         std::string literaler;  // 调用的函数
         bool in_protect;  // 是否在protect空间

+ 1 - 1
include/core/inter.inline.h

@@ -11,7 +11,7 @@ namespace aFuncore {
         activation = new_activation;
     }
 
-    inline InterStatus Inter::getStatus() const {
+    inline Inter::InterStatus Inter::getStatus() const {
         return status;
     }
 

+ 6 - 3
include/core/msg.h

@@ -4,7 +4,6 @@
 #include <mutex>
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.h"
 
 namespace aFuncore {
     class AFUN_CORE_EXPORT Message {
@@ -29,6 +28,10 @@ namespace aFuncore {
         virtual void topProgress() = 0;
     };
 
+    class Object;
+    class Activation;
+    class Inter;
+
     class AFUN_CORE_EXPORT NormalMessage : public TopMessage {
     public:
         explicit inline NormalMessage(Object *obj_);
@@ -53,8 +56,8 @@ namespace aFuncore {
         std::string error_type;
         std::string error_info;
         struct TrackBack{
-            const StringFilePath path;
-            FileLine line;
+            const aFuntool::StringFilePath path;
+            aFuntool::FileLine line;
         };
         std::list<TrackBack> trackback;
     };

+ 3 - 1
include/core/value.h

@@ -3,10 +3,12 @@
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
 #include "list"
-#include "core.h"
 #include "gc.h"
+#include "code.h"
 
 namespace aFuncore {
+    class Inter;
+
     class AFUN_CORE_EXPORT Object : public GcObject<class Object> {
     public:
         Inter &inter;

+ 10 - 1
include/core/var.h

@@ -2,11 +2,13 @@
 #define AFUN_VAR_H
 #include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.h"
 #include "gc.h"
 #include <list>
 
 namespace aFuncore {
+    class Inter;
+    class Object;
+
     class AFUN_CORE_EXPORT Var : public GcObject<class Var> {
     public:
         Inter &inter;
@@ -23,6 +25,13 @@ namespace aFuncore {
 
     class AFUN_CORE_EXPORT VarSpace : public GcObject<class VarSpace> {
     public:
+        typedef enum VarOperationFlat {
+            vof_success = 0,  // 成功
+            vof_not_var = 1,  // 变量不存在
+            vof_redefine_var = 2,  // 变量重复定义
+            vof_fail = 3,  // 存在其他错误
+        } VarOperationFlat;
+
         Inter &inter;
 
         explicit VarSpace(Inter &inter_);

+ 13 - 15
src/core/activation.cpp

@@ -1,11 +1,9 @@
-#include "activation.h"
-#include "value.h"
+#include "value.h"
 #include "inter.h"
 #include "init.h"
 #include "msg.h"
 #include "var.h"
 #include "code.h"
-#include "env-var.h"
 
 using namespace aFuncore;
 using namespace aFuntool;
@@ -47,20 +45,20 @@ Activation::~Activation(){
  */
 void Activation::runCode(Code *code) {
     auto code_type = code->getType();
-    if (code_type == code_start) {  // start 不处理 msg
+    if (code_type == Code::code_start) {  // start 不处理 msg
         auto *none = new Object("None", inter);
         down.pushMessage(new NormalMessage(none));
     } else {
-        if (code_type == code_element) {
+        if (code_type == Code::code_element) {
             runCodeElement(code);
         } else switch (code->getBlockType()) {
-            case block_p:  // 顺序执行
+            case Code::block_p:  // 顺序执行
                 runCodeBlockP(code);
                 break;
-            case block_b:
+            case Code::block_b:
                 runCodeBlockB(code);
                 break;
-            case block_c:
+            case Code::block_c:
                 runCodeBlockC(code);
                 break;
             default:
@@ -110,7 +108,7 @@ void Activation::runCodeBlockB(Code *code) {
     new FuncActivation(code, inter);
 }
 
-ActivationStatus ExeActivation::getCode(Code *&code){
+Activation::ActivationStatus ExeActivation::getCode(Code *&code){
     code = next;
     if (code == nullptr)
         return as_end;
@@ -150,13 +148,13 @@ FuncActivation::~FuncActivation(){
     delete call_func;
 }
 
-ActivationStatus FuncActivation::getCode(Code *&code){
+Activation::ActivationStatus FuncActivation::getCode(Code *&code){
     if (on_tail)
         return as_end;
 
     if (status == func_first) {
         switch (call->getBlockType()) {
-            case block_c:
+            case Code::block_c:
                 status = func_get_func;
                 code = call->getSon();
                 if (code == nullptr) {
@@ -168,13 +166,13 @@ ActivationStatus FuncActivation::getCode(Code *&code){
                 if (code->getFilePath() != nullptr)
                     path = code->getFilePath();
                 return as_run;
-            case block_b: {
+            case Code::block_b: {
                 std::string prefix;
-                if (!inter.getEnvVarSpace().findString("sys:prefix", prefix) || prefix.size() != PREFIX_COUNT)
+                if (!inter.getEnvVarSpace().findString("sys:prefix", prefix) || prefix.size() != Inter::PREFIX_COUNT)
                     prefix = "''";
-                char quote = prefix[prefix_quote];
+                char quote = prefix[Inter::prefix_quote];
                 for (Code *var = call->getSon(); var != nullptr; var = var->toNext()) {
-                    if (var->getType() != code_element || var->getPrefix() == quote || inter.checkLiteral(var->getElement()))
+                    if (var->getType() != Code::code_element || var->getPrefix() == quote || inter.checkLiteral(var->getElement()))
                         continue;
                     Object *obj = varlist->findObject(var->getElement());
                     if (obj == nullptr || !dynamic_cast<Function *>(obj) || !dynamic_cast<Function *>(obj)->isInfix())

+ 4 - 4
src/core/inter.cpp

@@ -101,18 +101,18 @@ void Inter::enable(){
 bool Inter::runCode(){
     while (activation != nullptr) {
         Code *code = nullptr;
-        ActivationStatus as = activation->getCode(code);
+        Activation::ActivationStatus as = activation->getCode(code);
         switch (as) {
-            case as_end: {
+            case Activation::as_end: {
                 Activation *prev = activation->toPrev();
                 delete activation;
                 activation = prev;
                 break;
             }
-            case as_run:
+            case Activation::as_run:
                 activation->runCode(code);
                 break;
-            case as_end_run:
+            case Activation::as_end_run:
                 activation->endRun();
                 break;
             default:

+ 20 - 20
src/core/var.cpp

@@ -33,7 +33,7 @@ Var *aFuncore::VarSpace::findVar(const std::string &name){
  * @param data 变量(Object)
  * @return
  */
-VarOperationFlat aFuncore::VarSpace::defineVar(const std::string &name, Object *data){
+VarSpace::VarOperationFlat aFuncore::VarSpace::defineVar(const std::string &name, Object *data){
     size_t index = time33(name) % VAR_HASH_SIZE;
     auto tmp = &var[index];
     for (NULL; *tmp != nullptr; tmp = &(*tmp)->next) {
@@ -53,7 +53,7 @@ VarOperationFlat aFuncore::VarSpace::defineVar(const std::string &name, Object *
  * @param data 变量(Var)
  * @return
  */
-VarOperationFlat aFuncore::VarSpace::defineVar(const std::string &name, Var *data){
+VarSpace::VarOperationFlat aFuncore::VarSpace::defineVar(const std::string &name, Var *data){
     size_t index = time33(name) % VAR_HASH_SIZE;
     auto tmp = &var[index];
     for (NULL; *tmp != nullptr; tmp = &(*tmp)->next) {
@@ -73,7 +73,7 @@ VarOperationFlat aFuncore::VarSpace::defineVar(const std::string &name, Var *dat
  * @param data 变量
  * @return
  */
-VarOperationFlat aFuncore::VarSpace::setVar(const std::string &name, Object *data){
+VarSpace::VarOperationFlat aFuncore::VarSpace::setVar(const std::string &name, Object *data){
     size_t index = time33(name) % VAR_HASH_SIZE;
     for (auto tmp = var[index]; tmp != nullptr; tmp = tmp->next) {
         if (tmp->name == name) {
@@ -89,7 +89,7 @@ VarOperationFlat aFuncore::VarSpace::setVar(const std::string &name, Object *dat
  * @param name 变量名
  * @return
  */
-VarOperationFlat aFuncore::VarSpace::delVar(const std::string &name){
+VarSpace::VarOperationFlat aFuncore::VarSpace::delVar(const std::string &name){
     size_t index = time33(name) % VAR_HASH_SIZE;
     for (auto tmp = var[index]; tmp != nullptr && tmp->next != nullptr; tmp = tmp->next) {
         if (tmp->next->name == name) {
@@ -125,7 +125,7 @@ aFuncore::VarList::VarList(VarList *varlist) {
  * @param data 变量(Object)
  * @return
  */
-VarOperationFlat aFuncore::ProtectVarSpace::defineVar(const std::string &name, Object *data){
+VarSpace::VarOperationFlat aFuncore::ProtectVarSpace::defineVar(const std::string &name, Object *data){
     return VarSpace::defineVar(name, data);
 }
 
@@ -137,7 +137,7 @@ VarOperationFlat aFuncore::ProtectVarSpace::defineVar(const std::string &name, O
  * @param data 变量(Var)
  * @return
  */
-VarOperationFlat aFuncore::ProtectVarSpace::defineVar(const std::string &name, Var *data){
+VarSpace::VarOperationFlat aFuncore::ProtectVarSpace::defineVar(const std::string &name, Var *data){
     return VarSpace::defineVar(name, data);
 }
 
@@ -149,7 +149,7 @@ VarOperationFlat aFuncore::ProtectVarSpace::defineVar(const std::string &name, V
  * @param data 变量(Var)
  * @return
  */
-VarOperationFlat aFuncore::ProtectVarSpace::setVar(const std::string &name, Object *data){
+VarSpace::VarOperationFlat aFuncore::ProtectVarSpace::setVar(const std::string &name, Object *data){
     if (is_protect)
         return findVar(name) ? vof_fail : vof_not_var;
     return VarSpace::setVar(name, data);
@@ -163,7 +163,7 @@ VarOperationFlat aFuncore::ProtectVarSpace::setVar(const std::string &name, Obje
  * @param data 变量(Var)
  * @return
  */
-VarOperationFlat aFuncore::ProtectVarSpace::delVar(const std::string &name){
+VarSpace::VarOperationFlat aFuncore::ProtectVarSpace::delVar(const std::string &name){
     if (is_protect)
         return findVar(name) ? vof_fail : vof_not_var;
     return VarSpace::delVar(name);
@@ -190,10 +190,10 @@ Var *aFuncore::VarList::findVar(const std::string &name){
  * @return
  */
 bool aFuncore::VarList::defineVar(const std::string &name, Object *data){
-    VarOperationFlat ret = vof_fail;
-    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == vof_fail; tmp++)
+    VarSpace::VarOperationFlat ret = VarSpace::vof_fail;
+    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == VarSpace::vof_fail; tmp++)
         ret = (*tmp)->defineVar(name, data);
-    return ret == vof_success;
+    return ret == VarSpace::vof_success;
 }
 
 /**
@@ -205,10 +205,10 @@ bool aFuncore::VarList::defineVar(const std::string &name, Object *data){
  * @return
  */
 bool aFuncore::VarList::defineVar(const std::string &name, Var *data){
-    VarOperationFlat ret = vof_fail;
-    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == vof_fail; tmp++)
+    VarSpace::VarOperationFlat ret = VarSpace::vof_fail;
+    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == VarSpace::vof_fail; tmp++)
         ret = (*tmp)->defineVar(name, data);
-    return ret == vof_success;
+    return ret == VarSpace::vof_success;
 }
 
 /**
@@ -220,10 +220,10 @@ bool aFuncore::VarList::defineVar(const std::string &name, Var *data){
  * @return
  */
 bool aFuncore::VarList::setVar(const std::string &name, Object *data){
-    VarOperationFlat ret = vof_not_var;
-    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == vof_not_var; tmp++)
+    VarSpace::VarOperationFlat ret = VarSpace::vof_not_var;
+    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == VarSpace::vof_not_var; tmp++)
         ret = (*tmp)->setVar(name, data);
-    return ret == vof_success;
+    return ret == VarSpace::vof_success;
 }
 
 /**
@@ -234,10 +234,10 @@ bool aFuncore::VarList::setVar(const std::string &name, Object *data){
  * @return
  */
 bool aFuncore::VarList::delVar(const std::string &name){
-    VarOperationFlat ret = vof_not_var;
-    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == vof_not_var; tmp++)
+    VarSpace::VarOperationFlat ret = VarSpace::vof_not_var;
+    for (auto tmp = varspace.begin(), end = varspace.end(); tmp != end && ret == VarSpace::vof_not_var; tmp++)
         ret = (*tmp)->delVar(name);
-    return ret == vof_success;
+    return ret == VarSpace::vof_success;
 }
 
 void VarList::connect(VarList *varlist){

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

@@ -4,7 +4,7 @@ using namespace aFuntool;
 
 int main() {
     Code *start = Code::create(1, "test.aun");
-    start->connect(Code::create("Test", 1))->connect(Code::create(block_p, Code::create(block_p, Code::create("Test3", 2), 2), 2));
+    start->connect(Code::create("Test", 1))->connect(Code::create(Code::block_p, Code::create(Code::block_p, Code::create("Test3", 2), 2), 2));
     start->displayAll();
     std::string md5 = start->getMD5All_v1();
     printf("md5: %s\n", md5.c_str());

+ 6 - 6
test/src/run-code.cpp

@@ -34,7 +34,7 @@ class Func1 : public Function {
 public:
     explicit Func1(Inter &inter_) : Function("Function", inter_) {
         func_code = (Code::create(0, "run-code.aun"));
-        func_code->connect(Code::create(block_p, Code::create("test-var", 1), 0));
+        func_code->connect(Code::create(Code::block_p, Code::create("test-var", 1), 0));
     }
 
     ~Func1() override {
@@ -53,7 +53,7 @@ class Literaler1 : public Literaler {
 public:
     explicit Literaler1(Inter &inter_) : Literaler("Data", inter_) {
         func_code = (Code::create(0, "run-code.aun"));
-        func_code->connect(Code::create(block_p, Code::create("test-var", 1), 0));
+        func_code->connect(Code::create(Code::block_p, Code::create("test-var", 1), 0));
     }
 
     ~Literaler1() override {
@@ -71,7 +71,7 @@ class CBV1 : public CallBackVar {
 public:
     explicit CBV1(Inter &inter_) : CallBackVar("CBV1", inter_) {
         func_code = (Code::create(0, "run-code.aun"));
-        func_code->connect(Code::create(block_p, Code::create("test-var", 1), 0));
+        func_code->connect(Code::create(Code::block_p, Code::create("test-var", 1), 0));
     }
 
     ~CBV1() override {
@@ -107,7 +107,7 @@ int main() {
 
     {
         auto code = (Code::create(0, "run-code.aun"));
-        code->connect(Code::create(block_p, Code::create("test-var", 1), 0));
+        code->connect(Code::create(Code::block_p, Code::create("test-var", 1), 0));
         inter.runCode(code);
         Code::destruct(code);
         fputs_stdout("\n");
@@ -118,7 +118,7 @@ int main() {
         arg->connect(Code::create("test-var", 1));
 
         auto code = (Code::create(0, "run-code.aun"));
-        code->connect(Code::create(block_c, arg, 0));
+        code->connect(Code::create(Code::block_c, arg, 0));
         inter.runCode(code);
         Code::destruct(code);
         fputs_stdout("\n");
@@ -129,7 +129,7 @@ int main() {
         arg->connect(Code::create("test-func", 1));
 
         auto code = (Code::create(0, "run-code.aun"));
-        code->connect(Code::create(block_b, arg, 0));
+        code->connect(Code::create(Code::block_b, arg, 0));
         inter.runCode(code);
         Code::destruct(code);
         fputs_stdout("\n");