Эх сурвалжийг харах

refactor & feat: 增加__del__函数, 重构结构体名字

重构了继承和属于的名字
继承: father -> inherit
属于: father -> belong

在value释放之前必然调用__del__函数并且忽略错误(如果存在)
SongZihuan 4 жил өмнө
parent
commit
fe350bc03c

+ 53 - 5
gc/gc.c

@@ -5,12 +5,12 @@ void gc_iterLinkValue(LinkValue *value){
         return;
     gc_addLink(&value->gc_status);
     if (!gc_IterAlready(&value->gc_status)){
-        gc_iterLinkValue(value->father);
+        gc_iterLinkValue(value->belong);
         gc_iterValue(value->value);
     }
 }
 
-void gc_fatherValue(FatherValue *value){
+void gc_fatherValue(Inherit *value){
     for (PASS; value != NULL; value = value->next)
         gc_iterLinkValue(value->value);
 }
@@ -23,7 +23,8 @@ void gc_iterValue(Value *value){
         return;
     gc_varList(value->object.var);
     gc_varList(value->object.out_var);
-    gc_fatherValue(value->object.father);
+    gc_fatherValue(value->object.inherit);
+    gc_resetValue(value);
     switch (value->type) {
         case list:
             for (int i=0;i < value->data.list.size;i++)
@@ -96,10 +97,55 @@ void gc_checkBase(Inter *inter){
             gc_iterVar(var_base);
 }
 
+void gc_checkDel(Inter *inter){
+    for (Value *value = inter->base; value != NULL; value = value->gc_next)
+        if (!gc_needFree(&value->gc_status))
+            gc_resetValue(value);
+        else if (value->gc_status.c_value == not_free){
+            if (needDel(value, inter)){
+                gc_iterValue(value);
+                value->gc_status.c_value = run_del;
+            }
+            else
+                value->gc_status.c_value = need_free;
+        }
+}
+
+void gc_runDelAll(Inter *inter){
+    Result result;
+    setResultCore(&result);
+    for (Value *value = inter->base; value != NULL; value = value->gc_next) {
+        freeResult(&result);
+        gc_addTmpLink(&value->gc_status);
+        if (needDel(value, inter)) {
+            callDel(value, &result, inter, inter->var_list);
+            if (!run_continue_type(result.type))
+                printError(&result, inter, true);
+        }
+        gc_freeTmpLink(&value->gc_status);
+    }
+}
+
+void gc_runDel(Inter *inter, VarList *var_list){
+    Result result;
+    setResultCore(&result);
+    for (Value *value = inter->base; value != NULL; value = value->gc_next) {
+        freeResult(&result);
+        if (value->gc_status.c_value == run_del) {
+            gc_addTmpLink(&value->gc_status);
+            callDel(value, &result, inter, var_list);
+            if (!run_continue_type(result.type))
+                printError(&result, inter, true);
+            gc_freeTmpLink(&value->gc_status);
+            value->gc_status.c_value = need_free;
+        }
+    }
+}
+
 void gc_freeBase(Inter *inter){
 #if START_GC
     for (Value **value_base = &inter->base; *value_base != NULL;)
-        if (gc_needFree(&(*value_base)->gc_status))
+        if (gc_needFreeValue(*value_base))
             freeValue(value_base);
         else
             value_base = &(*value_base)->gc_next;
@@ -124,7 +170,7 @@ void gc_freeBase(Inter *inter){
 #endif
 }
 
-void gc_run(Inter *inter, int var_list, int link_value, int value, ...){
+void gc_run(Inter *inter, VarList *run_var, int var_list, int link_value, int value, ...){
 #if START_GC
     gc_resetBase(inter);
     va_list arg;
@@ -143,6 +189,8 @@ void gc_run(Inter *inter, int var_list, int link_value, int value, ...){
     }
     va_end(arg);
     gc_checkBase(inter);
+    gc_checkDel(inter);
     gc_freeBase(inter);
+    gc_runDel(inter, run_var);
 #endif
 }

+ 10 - 3
gc/set.c

@@ -9,6 +9,7 @@ void setGC(GCStatus *gcs){
     resetGC(gcs);
     gcs->tmp_link = 0;
     gcs->statement_link = 0;
+    gcs->c_value = not_free;
 }
 
 void gc_addTmpLink(GCStatus *gcs){
@@ -38,7 +39,13 @@ bool gc_IterAlready(GCStatus *gcs){
 }
 
 bool gc_needFree(GCStatus *gcs){
-    if (gcs->statement_link == 0 && gcs->tmp_link == 0 && gcs->link == 0)
-        return true;
-    return false;
+    return (gcs->statement_link == 0 && gcs->tmp_link == 0 && gcs->link == 0);
+}
+
+void gc_resetValue(Value *value){
+    value->gc_status.c_value = not_free;
+}
+
+bool gc_needFreeValue(Value *value){
+    return (gc_needFree(&value->gc_status) && value->gc_status.c_value == need_free);
 }

+ 6 - 6
include/__macro.h

@@ -10,12 +10,12 @@
 #define HASH_INDEX unsigned int
 
 #define INTER_FUNCTIONSIG_CORE struct Inter *inter, struct VarList *var_list
-#define INTER_FUNCTIONSIG_NOT_ST struct LinkValue *father, struct Result *result, INTER_FUNCTIONSIG_CORE
+#define INTER_FUNCTIONSIG_NOT_ST struct LinkValue *belong, struct Result *result, INTER_FUNCTIONSIG_CORE
 #define INTER_FUNCTIONSIG struct Statement *st, INTER_FUNCTIONSIG_NOT_ST
 
 #define CALL_INTER_FUNCTIONSIG_CORE(var_list) inter, var_list
-#define CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father) father, result, CALL_INTER_FUNCTIONSIG_CORE(var_list)
-#define CALL_INTER_FUNCTIONSIG(st, var_list, result, father) st, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father)
+#define CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong) belong, result, CALL_INTER_FUNCTIONSIG_CORE(var_list)
+#define CALL_INTER_FUNCTIONSIG(st, var_list, result, belong) st, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong)
 
 #define run_continue_type(type) (type == not_return || type == operation_return)
 #define run_continue(result) (result->type == not_return || result->type == operation_return)
@@ -23,7 +23,7 @@
 #define freeBase(element, return_) do{if(element == NULL)goto return_;}while(0)
 
 #define OfficialFunctionSig struct Argument *arg, INTER_FUNCTIONSIG_NOT_ST
-#define CALL_OfficialFunction(arg, var_list, result, father) arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father)
-#define RegisteredFunctionSig struct LinkValue *father, INTER_FUNCTIONSIG_CORE
-#define CALL_RegisteredFunction(father, var_list) father, CALL_INTER_FUNCTIONSIG_CORE(var_list)
+#define CALL_OfficialFunction(arg, var_list, result, belong) arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong)
+#define RegisteredFunctionSig struct LinkValue *belong, INTER_FUNCTIONSIG_CORE
+#define CALL_RegisteredFunction(belong, var_list) belong, CALL_INTER_FUNCTIONSIG_CORE(var_list)
 #endif //VIRTUALMATH___MACRO_H

+ 11 - 1
include/gc.h

@@ -7,6 +7,11 @@ struct GCStatus{
     long int tmp_link;  // tmp link的次数
     long int statement_link;  // statement link的次数
     long int link;  // 被直接link的次数
+    enum {
+        not_free,
+        run_del,
+        need_free,
+    } c_value;  // value的计数 (先call __del__ 后释放)
     bool continue_;  // 是否迭代过
 };
 
@@ -28,8 +33,13 @@ void gc_freeStatementLink(GCStatus *gcs);
 void gc_freeTmpLink(GCStatus *gcs);
 bool gc_IterAlready(GCStatus *gcs);
 bool gc_needFree(GCStatus *gcs);
+void gc_resetValue(struct Value *value);
+bool gc_needFreeValue(struct Value *value);
 
 void gc_freeBase(struct Inter *inter);
+void gc_checkDel(struct Inter *inter);
+void gc_runDelAll(struct Inter *inter);
+void gc_runDel(struct Inter *inter, struct VarList *var_list);
 void gc_checkBase(struct Inter *inter);
 void gc_resetBase(struct Inter *inter);
 
@@ -42,6 +52,6 @@ void gc_varList(struct VarList *vl);
 void gc_iterFreezeVarList(struct VarList *freeze, struct VarList *base, bool is_lock);
 void gc_freeze(struct Inter *inter, struct VarList *freeze, struct VarList *base, bool is_lock);
 
-void gc_run(struct Inter *inter, int var_list, int link_value, int value, ...);
+void gc_run(struct Inter *inter, struct VarList *run_var, int var_list, int link_value, int value, ...);
 
 #endif //VIRTUALMATH_GC_H

+ 1 - 1
include/ofunc.h

@@ -15,7 +15,7 @@
 
 struct Argument;
 struct VarList;
-struct FatherValue;
+struct Inherit;
 struct Inter;
 
 struct NameFunc{

+ 2 - 2
include/parameter.h

@@ -89,8 +89,8 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
                         INTER_FUNCTIONSIG_NOT_ST);
 ResultType argumentToParameter(Argument **call_ad, Parameter **function_ad, VarList *function_var, INTER_FUNCTIONSIG_NOT_ST);
 
-FatherValue *setFatherCore(FatherValue *father_tmp);
-FatherValue *setFather(Argument *call);
+Inherit *setFatherCore(Inherit *father_tmp);
+Inherit *setFather(Argument *call);
 bool checkFormal(Parameter *pt);
 
 bool checkArgument(int c_value, int c_name, int type_value, int type_name, Argument *arg);

+ 23 - 20
include/value.h

@@ -7,7 +7,7 @@
 
 struct VarList;
 struct Argument;
-struct FatherValue;
+struct Inherit;
 
 typedef enum ResultType (*OfficialFunction)(OfficialFunctionSig);
 typedef void (*Registered)(RegisteredFunctionSig);
@@ -36,7 +36,7 @@ struct Value{
     struct {
         struct VarList *var;
         struct VarList *out_var;
-        struct FatherValue *father;
+        struct Inherit *inherit;
     } object;
     union data{
         struct Number{
@@ -88,7 +88,7 @@ struct LinkValue{
     struct GCStatus gc_status;
     enum ValueAuthority aut;
     struct Value *value;
-    struct LinkValue *father;
+    struct LinkValue *belong;
     struct LinkValue *gc_next;
     struct LinkValue *gc_last;
 };
@@ -121,9 +121,9 @@ struct Error{
     struct Error *next;
 };
 
-struct FatherValue{
+struct Inherit{
     struct LinkValue *value;
-    struct FatherValue *next;
+    struct Inherit *next;
 };
 
 typedef struct Inter Inter;
@@ -131,12 +131,12 @@ typedef struct Value Value;
 typedef struct LinkValue LinkValue;
 typedef struct Result Result;
 typedef struct Error Error;
-typedef struct FatherValue FatherValue;
+typedef struct Inherit Inherit;
 typedef enum ResultType ResultType;
 
-Value *makeObject(Inter *inter, VarList *object, VarList *out_var, FatherValue *father);
+Value *makeObject(Inter *inter, VarList *object, VarList *out_var, Inherit *inherit);
 void freeValue(Value **Value);
-LinkValue *makeLinkValue(Value *value, LinkValue *linkValue,Inter *inter);
+LinkValue *makeLinkValue(Value *value, LinkValue *belong, Inter *inter);
 void freeLinkValue(LinkValue **value);
 LinkValue *copyLinkValue(LinkValue *value, Inter *inter);
 Value *makeNoneValue(Inter *inter);
@@ -146,16 +146,16 @@ Value *makeNumberValue(long num, Inter *inter);
 Value *makeStringValue(char *str, Inter *inter);
 Value *makeVMFunctionValue(struct Statement *st, struct Parameter *pt, struct VarList *var_list, Inter *inter);
 Value *makeCFunctionValue(OfficialFunction of, VarList *var_list, Inter *inter);
-Value *makeClassValue(VarList *var_list, Inter *inter, FatherValue *father);
+Value *makeClassValue(VarList *var_list, Inter *inter, Inherit *father);
 Value *makeListValue(struct Argument **arg_ad, Inter *inter, enum ListType type);
 Value *makeDictValue(struct Argument **arg_ad, bool new_hash, INTER_FUNCTIONSIG_NOT_ST);
 
 void setResultCore(Result *ru);
-void setResult(Result *ru, Inter *inter, LinkValue *father);
-void setResultBase(Result *ru, Inter *inter, LinkValue *father);
-void setResultErrorSt(Result *ru, Inter *inter, char *error_type, char *error_message, Statement *st, LinkValue *father, bool new);
-void setResultError(Result *ru, Inter *inter, char *error_type, char *error_message, long int line, char *file, LinkValue *father, bool new);
-void setResultOperationNone(Result *ru, Inter *inter, LinkValue *father);
+void setResult(Result *ru, Inter *inter, LinkValue *belong);
+void setResultBase(Result *ru, Inter *inter, LinkValue *belong);
+void setResultErrorSt(Result *ru, Inter *inter, char *error_type, char *error_message, Statement *st, LinkValue *belong, bool new);
+void setResultError(Result *ru, Inter *inter, char *error_type, char *error_message, long int line, char *file, LinkValue *belong, bool new);
+void setResultOperationNone(Result *ru, Inter *inter, LinkValue *belong);
 void setResultOperation(Result *ru, LinkValue *value);
 void setResultOperationBase(Result *ru, LinkValue *value);
 void freeResult(Result *ru);
@@ -171,11 +171,14 @@ void printLinkValue(LinkValue *value, char *first, char *last, FILE *debug);
 
 bool isType(Value *value, enum ValueType type);
 
-FatherValue *makeFatherValue(LinkValue *value);
-FatherValue *copyFatherValue(FatherValue *value);
-FatherValue *freeFatherValue(FatherValue *value);
-FatherValue *connectFatherValue(FatherValue *base, FatherValue *back);
-FatherValue *connectSafeFatherValue(FatherValue *base, FatherValue *back);
+Inherit *makeInherit(LinkValue *value);
+Inherit *copyInherit(Inherit *value);
+Inherit *freeInherit(Inherit *value);
+Inherit *connectInherit(Inherit *base, Inherit *back);
+Inherit *connectSafeInherit(Inherit *base, Inherit *back);
 bool checkAttribution(Value *self, Value *father);
-FatherValue *getFatherFromValue(Value *value, Inter *inter);
+
+Inherit *getInheritFromValue(Value *value, Inter *inter);
+bool callDel(Value *object_value, Result *result, Inter *inter, VarList *var_list);
+bool needDel(Value *object_value, Inter *inter);
 #endif //VIRTUALMATH_VALUE_H

+ 3 - 4
include/var.h

@@ -47,8 +47,8 @@ VarList *makeVarList(Inter *inter, bool make_hash);
 VarList *freeVarList(VarList *vl);
 
 HASH_INDEX time33(char *key);
-LinkValue *findVar(char *name, bool del_var, INTER_FUNCTIONSIG_CORE);
-LinkValue *findFromVarList(char *name, NUMBER_TYPE times, bool del_var, INTER_FUNCTIONSIG_CORE);
+LinkValue *findVar(char *name, int operating, INTER_FUNCTIONSIG_CORE);
+LinkValue *findFromVarList(char *name, NUMBER_TYPE times, int operating, INTER_FUNCTIONSIG_CORE);
 void addVar(char *name, LinkValue *value, LinkValue *name_, INTER_FUNCTIONSIG_CORE);
 void updateHashTable(HashTable *update, HashTable *new, Inter *inter);
 void addFromVarList(char *name, LinkValue *name_, NUMBER_TYPE times, LinkValue *value, INTER_FUNCTIONSIG_CORE);
@@ -59,8 +59,7 @@ VarList *copyVarListCore(VarList *base, Inter *inter);
 VarList *copyVarList(VarList *base, bool n_new, Inter *inter);
 VarList *connectVarListBack(VarList *base, VarList *back);
 bool comparVarList(VarList *dest, VarList *src);
-VarList *connectSafeVarListBack(VarList *base, VarList *back);
-VarList *makeObjectVarList(FatherValue *value, Inter *inter, VarList *base);
+VarList *makeObjectVarList(Inherit *value, Inter *inter, VarList *base);
 
 NUMBER_TYPE findDefault(DefaultVar *base, char *name);
 DefaultVar *connectDefaultVar(DefaultVar *base, char *name, NUMBER_TYPE times);

+ 1 - 1
ofunc/include/__base.h

@@ -4,7 +4,7 @@
 
 struct Inter;
 struct VarList;
-struct FatherValue;
+struct Inherit;
 struct LinkValue;
 struct Result;
 typedef enum ResultType ResultType;

+ 2 - 2
ofunc/include/__ofunc.h

@@ -5,8 +5,8 @@
 #include "__run.h"
 
 
-LinkValue *registeredFunctionCore(OfficialFunction of, char *name, struct LinkValue *father, INTER_FUNCTIONSIG_CORE);
+LinkValue *registeredFunctionCore(OfficialFunction of, char *name, struct LinkValue *belong, INTER_FUNCTIONSIG_CORE);
 void iterNameFunc(NameFunc list[],struct LinkValue *father, INTER_FUNCTIONSIG_CORE);
-Value *makeBaseChildClass(Value *father, Inter *inter);
+Value *makeBaseChildClass(Value *inherit, Inter *inter);
 
 #endif //VIRTUALMATH___OFUNC_H

+ 6 - 6
ofunc/src/__ofunc.c

@@ -1,8 +1,8 @@
 #include "__ofunc.h"
 
-LinkValue *registeredFunctionCore(OfficialFunction of, char *name, LinkValue *father, INTER_FUNCTIONSIG_CORE) {
-    LinkValue *value = makeLinkValue(makeCFunctionValue(of, var_list, inter), father, inter);
-    addStrVar(name, false, value, father, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+LinkValue *registeredFunctionCore(OfficialFunction of, char *name, LinkValue *belong, INTER_FUNCTIONSIG_CORE) {
+    LinkValue *value = makeLinkValue(makeCFunctionValue(of, var_list, inter), belong, inter);
+    addStrVar(name, false, value, belong, CALL_INTER_FUNCTIONSIG_CORE(var_list));
     return value;
 }
 
@@ -13,11 +13,11 @@ void iterNameFunc(NameFunc list[], LinkValue *father, INTER_FUNCTIONSIG_CORE){
     }
 }
 
-Value *makeBaseChildClass(Value *father, Inter *inter) {
-    FatherValue *father_value = NULL;
+Value *makeBaseChildClass(Value *inherit, Inter *inter) {
+    Inherit *father_value = NULL;
     Value *num = NULL;
     {
-        LinkValue *father_ = makeLinkValue(father, inter->base_father, inter);
+        LinkValue *father_ = makeLinkValue(inherit, inter->base_father, inter);
         Argument *arg = makeValueArgument(father_);
         gc_addTmpLink(&father_->gc_status);
         father_value = setFather(arg);

+ 1 - 1
ofunc/src/bool.c

@@ -6,7 +6,7 @@ void registeredBool(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("bool", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("bool", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 1 - 1
ofunc/src/dict.c

@@ -6,7 +6,7 @@ void registeredDict(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("dict", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("dict", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 1 - 1
ofunc/src/function.c

@@ -6,7 +6,7 @@ void registeredFunction(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("function", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("function", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 4 - 4
ofunc/src/io.c

@@ -7,11 +7,11 @@ ResultType vm_print(OfficialFunctionSig){
                            {.must=-1}};
     {
         int status;
-        status = parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        status = parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             return result->type;
         if (status != 1) {
-            setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", father, true);
+            setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", belong, true);
             return error_return;
         }
         freeResult(result);
@@ -30,11 +30,11 @@ ResultType vm_print(OfficialFunctionSig){
     else
         printf("\n");
 
-    setResultBase(result, inter, father);
+    setResultBase(result, inter, belong);
     return result->type;
 }
 
 void registeredIOFunction(RegisteredFunctionSig){
     NameFunc tmp[] = {{"print", vm_print, free_}, {NULL, NULL}};
-    iterNameFunc(tmp, father, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+    iterNameFunc(tmp, belong, CALL_INTER_FUNCTIONSIG_CORE(var_list));
 }

+ 1 - 1
ofunc/src/list.c

@@ -6,7 +6,7 @@ void registeredList(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("list", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("list", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 1 - 1
ofunc/src/num.c

@@ -6,7 +6,7 @@ void registeredNum(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("num", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("num", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 5 - 5
ofunc/src/object.c

@@ -10,7 +10,7 @@ ResultType object_new_(OfficialFunctionSig){
     int status = 1;
     arg = parserValueArgument(ap, arg, &status, NULL);
     if (status != 1){
-        setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", father, true);
+        setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", belong, true);
         return error_return;
     }
 
@@ -18,11 +18,11 @@ ResultType object_new_(OfficialFunctionSig){
         VarList *new_var = NULL;
         Value *new_object = NULL;
         Argument *father_arg = makeValueArgument(ap[1].value);
-        FatherValue *object_father = setFather(father_arg);
+        Inherit *object_father = setFather(father_arg);
         freeArgument(father_arg, true);
         new_var = copyVarList(ap[1].value->value->object.out_var, false, inter);
         new_object = makeObject(inter, NULL, new_var, object_father);
-        value = makeLinkValue(new_object, father, inter);
+        value = makeLinkValue(new_object, belong, inter);
         setResultOperation(result, value);
     }
 
@@ -31,7 +31,7 @@ ResultType object_new_(OfficialFunctionSig){
     if (_init_ != NULL){
         Result _init_result;
         setResultCore(&_init_result);
-        _init_->father = value;
+        _init_->belong = value;
 
         gc_addTmpLink(&_init_->gc_status);
         callBackCore(_init_, arg, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, &_init_result, value));
@@ -54,7 +54,7 @@ void registeredObject(RegisteredFunctionSig){
     VarList *object_backup = NULL;
     NameFunc tmp[] = {{"__new__", object_new_, class_static_}, {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("object", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("object", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
     object_backup = object_var->next;
     object_var->next = inter->var_list;

+ 1 - 1
ofunc/src/pass.c

@@ -6,7 +6,7 @@ void registeredEllipisis(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("ellipsis", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("ellipsis", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 1 - 1
ofunc/src/str.c

@@ -6,7 +6,7 @@ void registeredStr(RegisteredFunctionSig){
 //    VarList *object_backup = NULL;
 //    NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("str", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("str", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
 //    object_backup = object_var->next;
 //    object_var->next = inter->var_list;

+ 14 - 14
ofunc/src/sys.c

@@ -9,7 +9,7 @@ ResultType vm_super(OfficialFunctionSig){
                            {.must=-1}};
     setResultCore(result);
     {
-        parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             return result->type;
         freeResult(result);
@@ -18,16 +18,16 @@ ResultType vm_super(OfficialFunctionSig){
     arg_father = ap[0].value->value;
     arg_child = ap[1].value->value;
     if (arg_child == arg_father) {
-        if (arg_child->object.father != NULL){
-            result->value = copyLinkValue(arg_child->object.father->value, inter);
+        if (arg_child->object.inherit != NULL){
+            result->value = copyLinkValue(arg_child->object.inherit->value, inter);
             result->type = operation_return;
             gc_addTmpLink(&result->value->gc_status);
         } else
-            setResultError(result, inter, "SuperException", "Don't get next father", 0, "sys", father, true);
+            setResultError(result, inter, "SuperException", "Don't get next father", 0, "sys", belong, true);
         return result->type;
     }
 
-    for (FatherValue *self_father = arg_child->object.father; self_father != NULL; self_father = self_father->next) {
+    for (Inherit *self_father = arg_child->object.inherit; self_father != NULL; self_father = self_father->next) {
         if (self_father->value->value == arg_father) {
             if (self_father->next != NULL)
                 next_father = copyLinkValue(self_father->next->value, inter);
@@ -41,7 +41,7 @@ ResultType vm_super(OfficialFunctionSig){
         gc_addTmpLink(&result->value->gc_status);
     }
     else
-        setResultError(result, inter, "SuperException", "Don't get next father", 0, "sys", father, true);
+        setResultError(result, inter, "SuperException", "Don't get next father", 0, "sys", belong, true);
 
     return result->type;
 }
@@ -51,7 +51,7 @@ ResultType vm_setMethodCore(OfficialFunctionSig, enum FunctionPtType type){
     ArgumentParser ap[] = {{.type=name_value, .name="func", .must=1, .long_arg=false}, {.must=-1}};
     setResultCore(result);
     {
-        parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             return result->type;
         freeResult(result);
@@ -65,27 +65,27 @@ ResultType vm_setMethodCore(OfficialFunctionSig, enum FunctionPtType type){
 }
 
 ResultType vm_freemethod(OfficialFunctionSig){
-    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, father), free_);
+    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, belong), free_);
 }
 
 ResultType vm_staticmethod(OfficialFunctionSig){
-    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, father), static_);
+    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, belong), static_);
 }
 
 ResultType vm_classmethod(OfficialFunctionSig){
-    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, father), class_static_);
+    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, belong), class_static_);
 }
 
 ResultType vm_objectmethod(OfficialFunctionSig){
-    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, father), object_static_);
+    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, belong), object_static_);
 }
 
 ResultType vm_classfreemethod(OfficialFunctionSig){
-    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, father), class_free_);
+    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, belong), class_free_);
 }
 
 ResultType vm_objectfreemethod(OfficialFunctionSig){
-    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, father), object_free_);
+    return vm_setMethodCore(CALL_OfficialFunction(arg, var_list, result, belong), object_free_);
 }
 
 void registeredSysFunction(RegisteredFunctionSig){
@@ -97,5 +97,5 @@ void registeredSysFunction(RegisteredFunctionSig){
                       {"classmethod", vm_classfreemethod, free_},
                       {"objectmethod", vm_objectfreemethod, free_},
                       {NULL, NULL}};
-    iterNameFunc(tmp, father, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+    iterNameFunc(tmp, belong, CALL_INTER_FUNCTIONSIG_CORE(var_list));
 }

+ 19 - 19
ofunc/src/vobject.c

@@ -2,8 +2,8 @@
 
 typedef void (*base_opt)(LinkValue *, Result *, struct Inter *, Value *, Value *);
 
-void vobject_add_base(LinkValue *father, Result *result, struct Inter *inter, Value *left, Value *right) {
-    setResultOperationBase(result, makeLinkValue(NULL, father, inter));
+void vobject_add_base(LinkValue *belong, Result *result, struct Inter *inter, Value *left, Value *right) {
+    setResultOperationBase(result, makeLinkValue(NULL, belong, inter));
     if (left->type == number && right->type == number)
         result->value->value = makeNumberValue(left->data.num.num + right->data.num.num, inter);
     else if(left->type == string && right->type == string){
@@ -12,19 +12,19 @@ void vobject_add_base(LinkValue *father, Result *result, struct Inter *inter, Va
         memFree(new_string);
     }
     else
-        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", father, true);
+        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", belong, true);
 }
 
-void vobject_sub_base(LinkValue *father, Result *result, struct Inter *inter, Value *left, Value *right) {
-    setResultOperationBase(result, makeLinkValue(NULL, father, inter));
+void vobject_sub_base(LinkValue *belong, Result *result, struct Inter *inter, Value *left, Value *right) {
+    setResultOperationBase(result, makeLinkValue(NULL, belong, inter));
     if (left->type == number && right->type == number)
         result->value->value = makeNumberValue(left->data.num.num - right->data.num.num, inter);
     else
-        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", father, true);
+        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", belong, true);
 }
 
-void vobject_mul_base(LinkValue *father, Result *result, struct Inter *inter, Value *left, Value *right) {
-    setResultOperationBase(result, makeLinkValue(NULL, father, inter));
+void vobject_mul_base(LinkValue *belong, Result *result, struct Inter *inter, Value *left, Value *right) {
+    setResultOperationBase(result, makeLinkValue(NULL, belong, inter));
     if (left->type == number && right->type == number)
         result->value->value = makeNumberValue(left->data.num.num * right->data.num.num, inter);
     else if(left->type == number && right->type == string) {
@@ -39,15 +39,15 @@ void vobject_mul_base(LinkValue *father, Result *result, struct Inter *inter, Va
         memFree(new_string);
     }
     else
-        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", father, true);
+        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", belong, true);
 }
 
-void vobject_div_base(LinkValue *father, Result *result, struct Inter *inter, Value *left, Value *right) {
-    setResultOperationBase(result, makeLinkValue(NULL, father, inter));
+void vobject_div_base(LinkValue *belong, Result *result, struct Inter *inter, Value *left, Value *right) {
+    setResultOperationBase(result, makeLinkValue(NULL, belong, inter));
     if (left->type == number && right->type == number)
         result->value->value = makeNumberValue(left->data.num.num / right->data.num.num, inter);
     else
-        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", father, true);
+        setResultError(result, inter, "TypeException", "Get Not Support Value", 0, "sys", belong, true);
 }
 
 ResultType vobject_opt_core(OfficialFunctionSig, base_opt func){
@@ -58,7 +58,7 @@ ResultType vobject_opt_core(OfficialFunctionSig, base_opt func){
                            {.must=-1}};
     setResultCore(result);
     {
-        parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             return result->type;
         freeResult(result);
@@ -67,25 +67,25 @@ ResultType vobject_opt_core(OfficialFunctionSig, base_opt func){
     left = ap[0].value->value;
     right = ap[1].value->value;
 
-    func(father, result, inter, left, right);
+    func(belong, result, inter, left, right);
 
     return result->type;
 }
 
 ResultType vobject_add(OfficialFunctionSig){
-    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, father), vobject_add_base);
+    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, belong), vobject_add_base);
 }
 
 ResultType vobject_sub(OfficialFunctionSig){
-    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, father), vobject_sub_base);
+    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, belong), vobject_sub_base);
 }
 
 ResultType vobject_mul(OfficialFunctionSig){
-    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, father), vobject_mul_base);
+    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, belong), vobject_mul_base);
 }
 
 ResultType vobject_div(OfficialFunctionSig){
-    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, father), vobject_div_base);
+    return vobject_opt_core(CALL_OfficialFunction(arg, var_list, result, belong), vobject_div_base);
 }
 
 void registeredVObject(RegisteredFunctionSig){
@@ -98,7 +98,7 @@ void registeredVObject(RegisteredFunctionSig){
                       {"__div__", vobject_div, object_free_},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addStrVar("vobject", false, object, father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    addStrVar("vobject", false, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
 
     object_backup = object_var->next;
     object_var->next = inter->var_list;

+ 31 - 23
src/__run.c

@@ -9,17 +9,17 @@ ResultType getBaseVarInfo(char **name, int *times, INTER_FUNCTIONSIG){
         *times = 0;
         goto not_times;
     }
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.base_var.times, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.base_var.times, var_list, result, belong)))
         return result->type;
     if (!isType(result->value->value, number)){
-        setResultErrorSt(result, inter, "TypeException", "Don't get a number value", st, father, true);
+        setResultErrorSt(result, inter, "TypeException", "Don't get a number value", st, belong, true);
         return result->type;
     }
     *times = (int)result->value->value->data.num.num;
     freeResult(result);
 
     not_times:
-    value = makeLinkValue(makeStringValue(st->u.base_var.name, inter), father, inter);
+    value = makeLinkValue(makeStringValue(st->u.base_var.name, inter), belong, inter);
     setResultOperation(result, value);
 
     return result->type;
@@ -32,17 +32,17 @@ ResultType getBaseSVarInfo(char **name, int *times, INTER_FUNCTIONSIG){
         *times = 0;
         goto not_times;
     }
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.base_svar.times, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.base_svar.times, var_list, result, belong)))
         return result->type;
     if (!isType(result->value->value, number)){
-        setResultErrorSt(result, inter, "TypeException", "Don't get a number value", st, father, true);
+        setResultErrorSt(result, inter, "TypeException", "Don't get a number value", st, belong, true);
         return result->type;
     }
     *times = (int)result->value->value->data.num.num;
 
     freeResult(result);
     not_times:
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.base_svar.name, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.base_svar.name, var_list, result, belong)))
         return result->type;
 
     *name = getNameFromValue(result->value->value, inter);
@@ -53,11 +53,11 @@ ResultType getBaseSVarInfo(char **name, int *times, INTER_FUNCTIONSIG){
 
 ResultType getVarInfo(char **name, int *times, INTER_FUNCTIONSIG){
     if (st->type == base_var)
-        getBaseVarInfo(name, times, CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+        getBaseVarInfo(name, times, CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     else if (st->type == base_svar)
-        getBaseSVarInfo(name, times, CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+        getBaseSVarInfo(name, times, CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     else{
-        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
             return result->type;
         *name = getNameFromValue(result->value->value, inter);
         *times = 0;
@@ -114,8 +114,8 @@ ResultType setFunctionArgument(Argument **arg, LinkValue *function_value, long l
     Argument *tmp = NULL;
     enum FunctionPtType pt_type = function_value->value->data.function.function_data.pt_type;
     setResultCore(result);
-    if (function_value->father == NULL){
-        setResultError(result, inter, "ArgumentException", "Don't get self", line, file, father, true);
+    if (function_value->belong == NULL){
+        setResultError(result, inter, "ArgumentException", "Don't get self", line, file, belong, true);
         return error_return;
     }
 
@@ -127,28 +127,28 @@ ResultType setFunctionArgument(Argument **arg, LinkValue *function_value, long l
             break;
         case class_static_:
             tmp = makeValueArgument(function_value);
-            tmp->next = makeValueArgument(function_value->father);
+            tmp->next = makeValueArgument(function_value->belong);
             tmp->next->next = *arg;
             *arg = tmp;
             break;
         case object_static_:
             tmp = makeValueArgument(function_value);
-            if (function_value->father->value->type == class)
+            if (function_value->belong->value->type == class)
                 tmp->next = *arg;
             else {
-                tmp->next = makeValueArgument(function_value->father);
+                tmp->next = makeValueArgument(function_value->belong);
                 tmp->next->next = *arg;
             }
             *arg = tmp;
             break;
         case class_free_:
-            tmp = makeValueArgument(function_value->father);
+            tmp = makeValueArgument(function_value->belong);
             tmp->next = *arg;
             *arg = tmp;
             break;
         case object_free_:
-            if (function_value->father->value->type != class) {
-                tmp = makeValueArgument(function_value->father);
+            if (function_value->belong->value->type != class) {
+                tmp = makeValueArgument(function_value->belong);
                 tmp->next = *arg;
                 *arg = tmp;
             }
@@ -156,7 +156,7 @@ ResultType setFunctionArgument(Argument **arg, LinkValue *function_value, long l
         default:
             break;
     }
-    setResultBase(result, inter, father);
+    setResultBase(result, inter, belong);
     return result->type;
 }
 
@@ -173,21 +173,29 @@ void freeFunctionArgument(Argument *arg, Argument *base) {
 LinkValue *findStrVar(char *name, bool free_old, INTER_FUNCTIONSIG_CORE){
     LinkValue *tmp = NULL;
     char *name_ = setStrVarName(name, free_old, inter);
-    tmp = findFromVarList(name_, 0, false, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+    tmp = findFromVarList(name_, 0, 0, CALL_INTER_FUNCTIONSIG_CORE(var_list));
     memFree(name_);
     return tmp;
 }
 
-void addStrVar(char *name, bool free_old, LinkValue *value, LinkValue *father, INTER_FUNCTIONSIG_CORE){
+LinkValue *checkStrVar(char *name, bool free_old, INTER_FUNCTIONSIG_CORE){
+    LinkValue *tmp = NULL;
+    char *name_ = setStrVarName(name, free_old, inter);
+    tmp = findFromVarList(name_, 0, 2, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+    memFree(name_);
+    return tmp;
+}
+
+void addStrVar(char *name, bool free_old, LinkValue *value, LinkValue *belong, INTER_FUNCTIONSIG_CORE){
     char *var_name = setStrVarName(name, free_old, inter);
-    LinkValue *name_ = makeLinkValue(makeStringValue(var_name, inter), father, inter);
+    LinkValue *name_ = makeLinkValue(makeStringValue(var_name, inter), belong, inter);
     addFromVarList(var_name, name_, 0, value, CALL_INTER_FUNCTIONSIG_CORE(var_list));
     memFree(var_name);
 }
 
 LinkValue *findAttributes(char *name, bool free_old, LinkValue *value, Inter *inter) {
     LinkValue *attr = findStrVar(name, free_old, CALL_INTER_FUNCTIONSIG_CORE(value->value->object.var));
-    if (attr != NULL && attr->father->value != value->value && checkAttribution(value->value, attr->father->value))
-        attr->father = value;
+    if (attr != NULL && (attr->belong == NULL || attr->belong->value != value->value && checkAttribution(value->value, attr->belong->value)))
+        attr->belong = value;
     return attr;
 }

+ 1 - 0
src/include/__run.h

@@ -29,6 +29,7 @@ void newWithBranchYield(Statement *branch_st, Statement *node, StatementList *sl
 ResultType setFunctionArgument(struct Argument **arg, LinkValue *function_value, long line, char *file, INTER_FUNCTIONSIG_NOT_ST);
 void freeFunctionArgument(Argument *arg, Argument *base);
 LinkValue *findStrVar(char *name, bool free_old, INTER_FUNCTIONSIG_CORE);
+LinkValue *checkStrVar(char *name, bool free_old, INTER_FUNCTIONSIG_CORE);
 void addStrVar(char *name, bool free_old, LinkValue *value, LinkValue *father, INTER_FUNCTIONSIG_CORE);
 LinkValue *findAttributes(char *name, bool free_old, LinkValue *value, Inter *inter);
 #endif //VIRTUALMATH___RUN_H

+ 5 - 9
src/inter.c

@@ -34,9 +34,8 @@ Inter *makeInter(char *debug, LinkValue *father) {
     gc_addStatementLink(&tmp->data.none->gc_status);
 
     {
-        VarList *out_var = copyVarList(tmp->var_list, false, tmp);
-        Value *base_father_value = makeObject(tmp, out_var, NULL, NULL);
-        base_father = makeLinkValue(base_father_value, father, tmp);
+        Value *global_belong = makeObject(tmp, copyVarList(tmp->var_list, false, tmp), NULL, NULL);
+        base_father = makeLinkValue(global_belong, father, tmp);
         gc_addStatementLink(&base_father->gc_status);
         tmp->base_father = base_father;
     }
@@ -68,6 +67,7 @@ void setBaseInterData(struct Inter *inter){
 }
 
 void freeBaseInterData(struct Inter *inter){
+    gc_freeStatementLink(&inter->base_father->gc_status);
     gc_freeStatementLink(&inter->data.object->gc_status);
     gc_freeStatementLink(&inter->data.vobject->gc_status);
     gc_freeStatementLink(&inter->data.num->gc_status);
@@ -99,11 +99,7 @@ void freeBaseInterData(struct Inter *inter){
 
 void freeInter(Inter *inter, bool show_gc) {
     freeBase(inter, return_);
-
-    gc_freeStatementLink(&inter->base_father->gc_status);
-    inter->base_father = NULL;
-
-    freeVarList(inter->var_list);
+    gc_runDelAll(inter);
     freeBaseInterData(inter);
 
     if (show_gc && (printf("Enter '1' to show gc: "), getc(stdin) == '1')) {
@@ -111,7 +107,7 @@ void freeInter(Inter *inter, bool show_gc) {
         while (getc(stdin) != '\n')
             PASS;
     }
-
+    freeVarList(inter->var_list);
     while (inter->base != NULL)
         freeValue(&inter->base);
     while (inter->base_var != NULL)

+ 53 - 53
src/parameter.c

@@ -213,16 +213,16 @@ ResultType defaultParameter(Parameter **function_ad, NUMBER_TYPE *num, INTER_FUN
 
     for (*num = 0; function != NULL && function->type == name_par; (*num)++, function = function->next){
         LinkValue *value = NULL;
-        if(operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(function->data.value, var_list, result, father)))
+        if(operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(function->data.value, var_list, result, belong)))
             goto return_;
 
         value = result->value;
         freeResult(result);
-        assCore(function->data.name, value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        assCore(function->data.name, value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             goto return_;
     }
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
 
     return_:
     *function_ad = function;
@@ -247,11 +247,11 @@ ResultType argumentToVar(Argument **call_ad, NUMBER_TYPE *num, INTER_FUNCTIONSIG
             continue;
         }
         freeResult(result);
-        assCore(call->data.name, call->data.value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        assCore(call->data.name, call->data.value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             goto return_;
     }
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
 
     return_:
     *call_ad = call;
@@ -281,7 +281,7 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
         get = true;
 
         if (function->type == kwargs_par){
-            value = makeLinkValue(makeDictValue(NULL, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, NULL, father)), father, inter);
+            value = makeLinkValue(makeDictValue(NULL, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, NULL, belong)), belong, inter);
             value->value->data.dict.dict = var_list->hashtable;
             value->value->data.dict.size = max - *num;
             *status = true;
@@ -289,7 +289,7 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
         }
 
         freeResult(result);
-        getVarInfo(&str_name, &int_times, CALL_INTER_FUNCTIONSIG(name, var_list, result, father));
+        getVarInfo(&str_name, &int_times, CALL_INTER_FUNCTIONSIG(name, var_list, result, belong));
         if (!run_continue(result)) {
             memFree(str_name);
             *function_ad = function;
@@ -297,33 +297,33 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
         }
 
         freeResult(result);
-        value = findFromVarList(str_name, int_times, true, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+        value = findFromVarList(str_name, int_times, 1, CALL_INTER_FUNCTIONSIG_CORE(var_list));
         memFree(str_name);
 
         if(value == NULL) {
             get = false;
-            if (function->type == name_par && !operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(function->data.value, var_list, result, father))) {
+            if (function->type == name_par && !operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(function->data.value, var_list, result, belong))) {
                 value = result->value;
                 goto not_return;
             }
-            setResultErrorSt(result, inter, "ArgumentException", "Too less Argument", name, father, true);
+            setResultErrorSt(result, inter, "ArgumentException", "Too less Argument", name, belong, true);
             goto reutnr_;
         }
         else if ((name->aut == public_aut || name->aut == auto_aut) && (value->aut != public_aut && value->aut != auto_aut)) {
             setResultErrorSt(result, inter, "PermissionsException", "Wrong Permissions: access Argument as public",
                              name,
-                             father, true);
+                             belong, true);
             goto reutnr_;
         }
         else if ((name->aut == protect_aut) && (value->aut == private_aut)) {
             setResultErrorSt(result, inter, "PermissionsException", "Wrong Permissions: access variables as protect",
-                             name, father, true);
+                             name, belong, true);
             goto reutnr_;
         }
 
         not_return:
         freeResult(result);
-        assCore(name, value, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, father));
+        assCore(name, value, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, belong));
 
         if (!run_continue(result)) {
             *function_ad = function;
@@ -336,7 +336,7 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
             (*num)++;
     }
 
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     reutnr_:
     *function_ad = function;
     return result->type;
@@ -358,13 +358,13 @@ ResultType argumentToParameter(Argument **call_ad, Parameter **function_ad, VarL
 
     for (PASS; call != NULL && function != NULL && (call->type == value_arg) && function->type != args_par; call = call->next, function = function->next){
         Statement *name = function->type == value_par ? function->data.value : function->data.name;
-        assCore(name, call->data.value, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, father));
+        assCore(name, call->data.value, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, belong));
         if (!run_continue(result))
             goto return_;
         freeResult(result);
     }
 
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     return_:
     *call_ad = call;
     *function_ad = function;
@@ -383,7 +383,7 @@ ResultType iterParameter(Parameter *call, Argument **base_ad, bool is_dict, INTE
     setResultCore(result);
 
     for (PASS; call != NULL; call = call->next){
-        if(operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(call->data.value, var_list, result, father)))
+        if(operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(call->data.value, var_list, result, belong)))
             goto return_;
 
         if (call->type == value_par)
@@ -392,7 +392,7 @@ ResultType iterParameter(Parameter *call, Argument **base_ad, bool is_dict, INTE
             if (is_dict){
                 LinkValue *value = result->value;
                 setResultCore(result);
-                if(operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(call->data.name, var_list, result, father))) {
+                if(operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(call->data.name, var_list, result, belong))) {
                     gc_freeTmpLink(&value->gc_status);
                     goto return_;
                 }
@@ -414,7 +414,7 @@ ResultType iterParameter(Parameter *call, Argument **base_ad, bool is_dict, INTE
         }
         freeResult(result);
     }
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
 
     return_:
     *base_ad = base;
@@ -424,7 +424,7 @@ ResultType iterParameter(Parameter *call, Argument **base_ad, bool is_dict, INTE
 Argument * getArgument(Parameter *call, bool is_dict, INTER_FUNCTIONSIG_NOT_ST) {
     Argument *new_arg = NULL;
     setResultCore(result);
-    iterParameter(call, &new_arg, is_dict, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    iterParameter(call, &new_arg, is_dict, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     return new_arg;
 }
 
@@ -446,10 +446,10 @@ Argument * getArgument(Parameter *call, bool is_dict, INTER_FUNCTIONSIG_NOT_ST)
  */
 ResultType setParameter(long int line, char *file, Parameter *call_base, Parameter *function_base, VarList *function_var, LinkValue *function_father, INTER_FUNCTIONSIG_NOT_ST) {
     Argument *self_tmp = makeValueArgument(function_father);
-    Argument *father_tmp = makeValueArgument(function_father->father);
+    Argument *father_tmp = makeValueArgument(function_father->belong);
     Argument *call = NULL;
     setResultCore(result);
-    call = getArgument(call_base, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    call = getArgument(call_base, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     self_tmp->next = father_tmp;
     father_tmp->next = call;
     if (!run_continue(result)) {
@@ -488,9 +488,9 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
         if (call == NULL && function == NULL)
             status = finished;
         else if (call != NULL && function == NULL)
-            status = error_to_less;
-        else if ((call == NULL && function->type == value_par))
             status = error_to_more;
+        else if ((call == NULL && function->type == value_par))
+            status = error_to_less;
         else if (call != NULL && call->type == value_par && function->type == kwargs_par)
             status = error_kw;
         else if (call == NULL && function->type == name_par)  // 根据前面的条件, 已经决定function不会为NULL
@@ -507,13 +507,13 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
         freeResult(result);
         switch (status) {
             case match_status: {
-                argumentToParameter(&call, &function, function_var, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+                argumentToParameter(&call, &function, function_var, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
                 returnResult(result);
                 break;
             }
             case default_status: {
                 NUMBER_TYPE num = 0;
-                defaultParameter(&function, &num, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, father));
+                defaultParameter(&function, &num, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, belong));
                 returnResult(result);
                 break;
             }
@@ -523,14 +523,14 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
                 bool dict_status = false;
                 VarList *tmp = makeVarList(inter, true);
 
-                argumentToVar(&call, &set_num, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, father));
+                argumentToVar(&call, &set_num, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, belong));
                 if (!run_continue(result)) {
                     freeVarList(tmp);
                     goto return_;
                 }
 
                 freeResult(result);
-                parameterFromVar(&function, function_var, &get_num, set_num, &dict_status, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, father));
+                parameterFromVar(&function, function_var, &get_num, set_num, &dict_status, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, belong));
                 freeVarList(tmp);
                 if (!run_continue(result))
                     goto return_;
@@ -540,38 +540,38 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
                 break;
             }
             case mul_par: {
-                LinkValue *tmp = makeLinkValue(makeListValue(&call, inter, value_tuple), father, inter);
-                assCore(function->data.value, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, father));
+                LinkValue *tmp = makeLinkValue(makeListValue(&call, inter, value_tuple), belong, inter);
+                assCore(function->data.value, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, belong));
                 returnResult(result);
                 function = function->next;
                 break;
             }
             case space_kwargs:{
-                LinkValue *tmp = makeLinkValue(makeDictValue(NULL, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father)), father, inter);
+                LinkValue *tmp = makeLinkValue(makeDictValue(NULL, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong)), belong, inter);
                 returnResult(result);
                 freeResult(result);
 
-                assCore(function->data.value, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, father));
+                assCore(function->data.value, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, belong));
                 returnResult(result);
                 function = function->next;
                 break;
             }
             case error_to_less:
-                setResultError(result, inter, "ArgumentException", "Too less argument", line, file, father, true);
+                setResultError(result, inter, "ArgumentException", "Too less argument", line, file, belong, true);
                 goto return_;
             case error_to_more:
             to_more:
-                setResultError(result, inter, "ArgumentException", "Too more argument", line, file, father, true);
+                setResultError(result, inter, "ArgumentException", "Too more argument", line, file, belong, true);
                 goto return_;
             case error_kw:
-                setResultError(result, inter, "ArgumentException", "Value argument for double star", line, file, father, true);
+                setResultError(result, inter, "ArgumentException", "Value argument for double star", line, file, belong, true);
                 goto return_;
             default:
                 goto break_;
         }
     }
     break_:
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
 
     return_:
     gc_freeze(inter, function_var, NULL, false);
@@ -580,22 +580,22 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
     return result->type;
 }
 
-FatherValue *setFather(Argument *call) {
-    FatherValue *father_tmp = NULL;
+Inherit *setFather(Argument *call) {
+    Inherit *father_tmp = NULL;
     for (Argument *tmp = call; tmp != NULL && tmp->type == value_arg; tmp = tmp->next)
         if (tmp->data.value->value->type == class) {
-            father_tmp = connectFatherValue(father_tmp, makeFatherValue(tmp->data.value));
-            father_tmp = connectFatherValue(father_tmp, copyFatherValue(tmp->data.value->value->object.father));
+            father_tmp = connectInherit(father_tmp, makeInherit(tmp->data.value));
+            father_tmp = connectInherit(father_tmp, copyInherit(tmp->data.value->value->object.inherit));
         }
     return setFatherCore(father_tmp);
 }
 
-FatherValue *setFatherCore(FatherValue *father_tmp) {
-    FatherValue *base_father = NULL;
+Inherit *setFatherCore(Inherit *father_tmp) {
+    Inherit *base_father = NULL;
     while (father_tmp != NULL){
-        FatherValue *next = father_tmp->next;
+        Inherit *next = father_tmp->next;
         father_tmp->next = NULL;
-        base_father = connectSafeFatherValue(base_father, father_tmp);
+        base_father = connectSafeInherit(base_father, father_tmp);
         father_tmp = next;
     }
     return base_father;
@@ -645,7 +645,7 @@ int parserArgumentUnion(ArgumentParser ap[], Argument *arg, INTER_FUNCTIONSIG_NO
         int status = 1;
         arg = parserValueArgument(ap, arg, &status, &bak);
         if (status != 1){
-            setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", father, true);
+            setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", belong, true);
             return 0;
         }
         ap = bak;
@@ -655,29 +655,29 @@ int parserArgumentUnion(ArgumentParser ap[], Argument *arg, INTER_FUNCTIONSIG_NO
         int status;
 
         if (arg != NULL && arg->type != name_arg) {
-            setResultError(result, inter, "ArgumentException", "Too many Argument", 0, "sys", father, true);
+            setResultError(result, inter, "ArgumentException", "Too many Argument", 0, "sys", belong, true);
             return -6;
         }
 
-        status = parserNameArgument(ap, arg, &bak, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        status = parserNameArgument(ap, arg, &bak, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             return -1;
         if (status == -3){
             if (parserArgumentNameDefault(ap)->must != -1){
-                setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", father, true);
+                setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", belong, true);
                 return -7;
             }
         }
         else if (status == 0){
-            setResultError(result, inter, "ArgumentException", "Too many Argument", 0, "sys", father, true);
+            setResultError(result, inter, "ArgumentException", "Too many Argument", 0, "sys", belong, true);
             return -2;
         } else if (status == -4){
-            setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", father, true);
+            setResultError(result, inter, "ArgumentException", "Too less Argument", 0, "sys", belong, true);
             return -3;
         }
     } else{
         if (arg != NULL) {
-            setResultError(result, inter, "ArgumentException", "Too many Argument", 0, "sys", father, true);
+            setResultError(result, inter, "ArgumentException", "Too many Argument", 0, "sys", belong, true);
             return -4;
         }
     }
@@ -715,12 +715,12 @@ int parserNameArgument(ArgumentParser ap[], Argument *arg, ArgumentParser **bak,
     }
 
     tmp = makeVarList(inter, true);
-    argumentToVar(&arg, &set_num, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, father));
+    argumentToVar(&arg, &set_num, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, belong));
     if (!run_continue(result)) {
         return_ = -1;
         goto return_;
     }
-    setResultBase(result, inter, father);
+    setResultBase(result, inter, belong);
 
     for (PASS; ap->must != -1 && (ap->type == only_name || ap->type == name_value); ap++) {
         int status = parserArgumentVar(ap, inter, tmp);

+ 50 - 50
src/run.c

@@ -12,95 +12,95 @@ ResultType runStatement(INTER_FUNCTIONSIG) {
     ResultType type = not_return;
     switch (st->type) {
         case base_value:
-            type = getBaseValue(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = getBaseValue(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case base_var:
-            type = getVar(CALL_INTER_FUNCTIONSIG(st, var_list, result, father), getBaseVarInfo);
+            type = getVar(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong), getBaseVarInfo);
             break;
         case base_svar:
-            type = getVar(CALL_INTER_FUNCTIONSIG(st, var_list, result, father), getBaseSVarInfo);
+            type = getVar(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong), getBaseSVarInfo);
             break;
         case base_list:
-            type = getList(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = getList(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case base_dict:
-            type = getDict(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = getDict(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case base_lambda:
-            type = setLambda(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = setLambda(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case operation:
-            type = operationStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = operationStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case set_class:
-            type = setClass(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = setClass(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case set_function:
-            type = setFunction(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = setFunction(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case call_function:
-            type = callBack(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = callBack(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case if_branch:
-            type = ifBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = ifBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case while_branch:
-            type = whileBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = whileBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case with_branch:
-            type = withBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = withBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case try_branch:
-            type = tryBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = tryBranch(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case break_cycle:
-            type = breakCycle(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = breakCycle(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case continue_cycle:
-            type = continueCycle(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = continueCycle(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case rego_if:
-            type = regoIf(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = regoIf(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case restart:
-            type = restartCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = restartCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case return_code:
-            type = returnCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = returnCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case yield_code:
-            type = yieldCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = yieldCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case raise_code:
-            type = raiseCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = raiseCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case include_file:
-            type = includeFile(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = includeFile(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case import_file:
-            type = importFile(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = importFile(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case from_import_file:
-            type = fromImportFile(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = fromImportFile(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case default_var:
-            type = setDefault(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = setDefault(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case assert:
-            type = assertCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = assertCode(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case goto_:
-            type = gotoLabel(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            type = gotoLabel(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         default:
-            setResult(result, inter, father);
+            setResult(result, inter, belong);
             break;
     }
 
     if (run_continue_type(type) && result->value->aut == auto_aut)
         result->value->aut = st->aut;
     result->node = st;
-    gc_run(inter, 1, 0, 0, var_list);
+    gc_run(inter, var_list, 1, 0, 0, var_list);
     return type;
 }
 
@@ -117,22 +117,22 @@ ResultType iterStatement(INTER_FUNCTIONSIG) {
     setResultCore(result);
 
     if (st == NULL){
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
         return result->type;
     }
 
     do {
         for (base_st = st; base_st != NULL; PASS) {
             freeResult(result);
-            type = runStatement(CALL_INTER_FUNCTIONSIG(base_st, var_list, result, father));
+            type = runStatement(CALL_INTER_FUNCTIONSIG(base_st, var_list, result, belong));
             if (type == goto_return && result->times == 0){
                 Statement *label_st = checkLabel(st, result->label);
                 if (label_st == NULL){
-                    setResultErrorSt(result, inter, "GotoException", "Don't find label", st, father, true);
+                    setResultErrorSt(result, inter, "GotoException", "Don't find label", st, belong, true);
                     type = error_return;
                     break;
                 }
-                type = runLabel(CALL_INTER_FUNCTIONSIG(label_st, var_list, result, father));
+                type = runLabel(CALL_INTER_FUNCTIONSIG(label_st, var_list, result, belong));
                 if (!run_continue_type(type))
                     break;
                 base_st = label_st->next;
@@ -145,9 +145,9 @@ ResultType iterStatement(INTER_FUNCTIONSIG) {
     } while (type == restart_return && result->times == 0);
 
     if (type == not_return || type == restart_return)
-        setResultOperationNone(result, inter, father);
+        setResultOperationNone(result, inter, belong);
     result->node = base_st;
-    gc_run(inter, 1, 0, 0, var_list);
+    gc_run(inter, var_list, 1, 0, 0, var_list);
     return result->type;
 }
 
@@ -157,23 +157,23 @@ ResultType iterStatement(INTER_FUNCTIONSIG) {
  * @return
  */
 ResultType globalIterStatement(Result *result, Inter *inter, Statement *st) {
-    LinkValue *father = inter->base_father;
-    gc_addTmpLink(&father->gc_status);
+    LinkValue *belong = inter->base_father;
+    gc_addTmpLink(&belong->gc_status);
     Statement *base_st = NULL;
     VarList *var_list = NULL;
     enum ResultType type;
     do {
         for (base_st = st, var_list = inter->var_list; base_st != NULL; PASS) {
             freeResult(result);
-            type = runStatement(CALL_INTER_FUNCTIONSIG(base_st, var_list, result, father));
+            type = runStatement(CALL_INTER_FUNCTIONSIG(base_st, var_list, result, belong));
             if (type == goto_return){
                 Statement *label_st = checkLabel(st, result->label);
                 if (label_st == NULL){
-                    setResultErrorSt(result, inter, "GotoException", "Don't find label", st, father, true);
+                    setResultErrorSt(result, inter, "GotoException", "Don't find label", st, belong, true);
                     type = error_return;
                     break;
                 }
-                type = runLabel(CALL_INTER_FUNCTIONSIG(label_st, var_list, result, father));
+                type = runLabel(CALL_INTER_FUNCTIONSIG(label_st, var_list, result, belong));
                 if (!run_continue_type(type))
                     break;
                 base_st = label_st->next;
@@ -186,27 +186,27 @@ ResultType globalIterStatement(Result *result, Inter *inter, Statement *st) {
     } while (type == restart_return && result->times == 0);
 
     if (type != error_return && type != function_return)
-        setResultOperationNone(result, inter, father);
+        setResultOperationNone(result, inter, belong);
     result->node = base_st;
-    gc_freeTmpLink(&father->gc_status);
-    gc_run(inter, 1, 0, 0, var_list);
+    gc_freeTmpLink(&belong->gc_status);
+    gc_run(inter, var_list, 1, 0, 0, var_list);
     return result->type;
 }
 
 // 若需要中断执行, 则返回true
 bool operationSafeInterStatement(INTER_FUNCTIONSIG){
     ResultType type;
-    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (run_continue_type(type))
         return false;
     else if (type != return_code && type != error_return)
-        setResultErrorSt(result, inter, "ResultException", "Get Not Support Result", st, father, true);
+        setResultErrorSt(result, inter, "ResultException", "Get Not Support Result", st, belong, true);
     return true;
 }
 
 bool ifBranchSafeInterStatement(INTER_FUNCTIONSIG){
     ResultType type;
-    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (run_continue_type(type))
         return false;
     if (type == rego_return){
@@ -221,7 +221,7 @@ bool ifBranchSafeInterStatement(INTER_FUNCTIONSIG){
 
 bool cycleBranchSafeInterStatement(INTER_FUNCTIONSIG){
     ResultType type;
-    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (run_continue_type(type))
         return false;
     if (type == break_return || type == continue_return){
@@ -236,7 +236,7 @@ bool cycleBranchSafeInterStatement(INTER_FUNCTIONSIG){
 
 bool tryBranchSafeInterStatement(INTER_FUNCTIONSIG){
     ResultType type;
-    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (run_continue_type(type))
         return false;
     if (type == restart_return || type == goto_return)
@@ -246,7 +246,7 @@ bool tryBranchSafeInterStatement(INTER_FUNCTIONSIG){
 
 bool functionSafeInterStatement(INTER_FUNCTIONSIG){
     ResultType type;
-    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (type == error_return || result->type == yield_return)
         return true;
     else if (type == function_return)
@@ -258,7 +258,7 @@ bool functionSafeInterStatement(INTER_FUNCTIONSIG){
 
 bool blockSafeInterStatement(INTER_FUNCTIONSIG){
     ResultType type;
-    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    type = iterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (type == error_return || type == yield_return)
         return true;
     result->type = operation_return;

+ 63 - 61
src/runbranch.c

@@ -2,7 +2,7 @@
 
 static bool checkNumber(INTER_FUNCTIONSIG){
     if (!isType(result->value->value, number)) {
-        setResultErrorSt(result, inter, "TypeException", "Don't get a number value", st, father, true);
+        setResultErrorSt(result, inter, "TypeException", "Don't get a number value", st, belong, true);
         return false;
     }
     return true;
@@ -10,7 +10,7 @@ static bool checkNumber(INTER_FUNCTIONSIG){
 
 static bool checkString(INTER_FUNCTIONSIG){
     if (!isType(result->value->value, string)) {
-        setResultErrorSt(result, inter, "TypeException", "Don't get a string value", st, father, true);
+        setResultErrorSt(result, inter, "TypeException", "Don't get a string value", st, belong, true);
         return false;
     }
     return true;
@@ -94,7 +94,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
     for (PASS; if_list != NULL; if_list = if_list->next){
         freeResult(result);
         if (info_vl != NULL){
-            if (ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(info_vl, var_list, result, father))){
+            if (ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(info_vl, var_list, result, belong))){
                 set_result = false;
                 goto not_else;
             }
@@ -105,7 +105,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
         }
         else if (if_list->type == if_b){
             LinkValue *condition_value = NULL;
-            if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(if_list->condition, var_list, result, father))){
+            if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(if_list->condition, var_list, result, belong))){
                 set_result = false;
                 goto not_else;
             }
@@ -113,7 +113,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
             condition_value = result->value;
             freeResult(result);
             if (if_list->var != NULL) {
-                assCore(if_list->var, condition_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+                assCore(if_list->var, condition_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
                 if (!run_continue(result)){
                     set_result = false;
                     goto not_else;
@@ -124,7 +124,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
             bool condition = is_rego ? true : checkBool(condition_value->value);  // 若是rego则不执行checkbool的判断了
             if (condition){
                 is_rego = false;
-                if (ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(if_list->code, var_list, result, father))){
+                if (ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(if_list->code, var_list, result, belong))){
                     set_result = false;
                     goto not_else;
                 }
@@ -138,7 +138,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
             }
         }
         else{
-            if (ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(if_list->code, var_list, result, father))){
+            if (ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(if_list->code, var_list, result, belong))){
                 set_result = false;
                 goto not_else;
             }
@@ -147,7 +147,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
             freeResult(result);
         }
     }
-    if (else_st != NULL && ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, var_list, result, father))) {
+    if (else_st != NULL && ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, var_list, result, belong))) {
         set_result = false;
         result_from = info_else_branch;
     }
@@ -155,7 +155,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
         freeResult(result);
 
     not_else:
-    if (finally != NULL && ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, father))){
+    if (finally != NULL && ifBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, belong))){
         if (!set_result)
             freeResult(result);
         set_result = false;
@@ -176,7 +176,7 @@ ResultType ifBranch(INTER_FUNCTIONSIG) {
         else
             var_list = popVarList(var_list);
     if (set_result)
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
     return result->type;
 }
 
@@ -219,7 +219,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
     }
 
 
-    if (first != NULL && cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(first, var_list, result, father))) {
+    if (first != NULL && cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(first, var_list, result, belong))) {
         result_from = info_first_do;
         set_result = false;
     }
@@ -244,7 +244,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
             goto do_after;
         }
 
-        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(while_list->condition, var_list, result, father))){
+        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(while_list->condition, var_list, result, belong))){
             set_result = false;
             goto not_else;
         }
@@ -252,7 +252,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
         condition_value = result->value;
         freeResult(result);
         if (while_list->var != NULL){
-            assCore(while_list->var, condition_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+            assCore(while_list->var, condition_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
             if (!run_continue(result)){
                 set_result = false;
                 goto not_else;
@@ -264,7 +264,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
         do_while = false;
         if (condition){
             do_while_st:
-            if (cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(while_st, var_list, result, father))){
+            if (cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(while_st, var_list, result, belong))){
                 set_result = false;
                 goto not_else;
             }
@@ -278,7 +278,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
         do_after:
         if (after_st == NULL)
             continue;
-        if (cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(after_st, var_list, result, father))){
+        if (cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(after_st, var_list, result, belong))){
             result_from = info_after_do;
             set_result = false;
             goto not_else;
@@ -292,7 +292,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
     }
 
     run_else:
-    if (!is_break && else_st != NULL && cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, var_list, result, father))) {
+    if (!is_break && else_st != NULL && cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, var_list, result, belong))) {
         result_from = info_else_branch;
         set_result = false;
     }
@@ -300,7 +300,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
         freeResult(result);
 
     not_else:
-    if (finally != NULL && cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, father))){
+    if (finally != NULL && cycleBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, belong))){
         if (!set_result)
             freeResult(result);
         set_result = false;
@@ -321,7 +321,7 @@ ResultType whileBranch(INTER_FUNCTIONSIG) {
         else
             var_list = popVarList(var_list);
     if (set_result)
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
     return result->type;
 }
 
@@ -334,6 +334,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
     LinkValue *_enter_ = NULL;
     LinkValue *_exit_ = NULL;
     LinkValue *value = NULL;
+    LinkValue *with_belong = belong;
     bool set_result = true;
     bool yield_run;
     enum StatementInfoStatus result_from = info_vl_branch;
@@ -366,12 +367,13 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
         }
     }
     else {
-        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(with_list->condition, var_list, result, father))) {
+        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(with_list->condition, var_list, result, belong))) {
             set_result = false;
             goto run_finally;
         }
 
         if (with_list->var == NULL) {
+            with_belong = result->value;
             new = copyVarListCore(result->value->value->object.var, inter);
             new->next = var_list;
             freeResult(result);
@@ -388,7 +390,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
                 _enter_ = NULL;
                 _exit_ = NULL;
                 value = NULL;
-                setResultErrorSt(result, inter, "EnterException", "Get Not Support Value to Enter with", st, father, true);
+                setResultErrorSt(result, inter, "EnterException", "Get Not Support Value to Enter with", st, belong, true);
                 set_result = false;
                 goto run_finally;
             }
@@ -407,7 +409,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
             new = pushVarList(var_list, inter);
             enter_value = result->value;
             freeResult(result);
-            assCore(with_list->var, enter_value, CALL_INTER_FUNCTIONSIG_NOT_ST(new, result, father));
+            assCore(with_list->var, enter_value, CALL_INTER_FUNCTIONSIG_NOT_ST(new, result, belong));
             if (!run_continue(result)) {
                 set_result = false;
                 popVarList(new);
@@ -423,7 +425,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
     gc_freeze(inter, new, var_list, true);
     if (vl_info == NULL)
         vl_info = with_list->code;
-    if (tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(vl_info, new, result, father))) {
+    if (tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(vl_info, new, result, with_belong))) {
         set_result = false;
         if (result->type == yield_return)
             goto run_finally;
@@ -432,7 +434,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
         freeResult(result);
 
     run_else:
-    if (else_st != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, new, &else_tmp, father))) {
+    if (else_st != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, new, &else_tmp, with_belong))) {
         if (!set_result)
             freeResult(result);
         set_result = false;
@@ -462,7 +464,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
     }
 
     run_finally:
-    if (finally != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, father))){
+    if (finally != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, belong))){
         if (!set_result)
             freeResult(result);
         set_result = false;
@@ -501,7 +503,7 @@ ResultType withBranch(INTER_FUNCTIONSIG) {
     }
 
     if (set_result)
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
     return result->type;
 }
 
@@ -540,7 +542,7 @@ ResultType tryBranch(INTER_FUNCTIONSIG) {
         goto not_else;
     }
 
-    if (try == NULL || !tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(try, var_list, result, father))){
+    if (try == NULL || !tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(try, var_list, result, belong))){
         freeResult(result);
         goto not_except;
     }
@@ -556,7 +558,7 @@ ResultType tryBranch(INTER_FUNCTIONSIG) {
     error_value = result->value;
     freeResult(result);
     if (except_list->var != NULL){
-        assCore(except_list->var, error_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        assCore(except_list->var, error_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result)){
             set_result = false;
             goto not_else;
@@ -567,7 +569,7 @@ ResultType tryBranch(INTER_FUNCTIONSIG) {
     run_except:
     if (info_vl == NULL)
         info_vl = except_list->code;
-    if (tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(info_vl, var_list, result, father))) {
+    if (tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(info_vl, var_list, result, belong))) {
         result_from = info_vl_branch;
         set_result = false;
     }
@@ -576,7 +578,7 @@ ResultType tryBranch(INTER_FUNCTIONSIG) {
     goto not_else;
 
     not_except:
-    if (else_st != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, var_list, result, father))) {
+    if (else_st != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(else_st, var_list, result, belong))) {
         set_result = false;
         result_from = info_else_branch;
     }
@@ -584,7 +586,7 @@ ResultType tryBranch(INTER_FUNCTIONSIG) {
         freeResult(result);
 
     not_else:
-    if (finally != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, father))){
+    if (finally != NULL && tryBranchSafeInterStatement(CALL_INTER_FUNCTIONSIG(finally, var_list, &finally_tmp, belong))){
         if (!set_result)
             freeResult(result);
         set_result = false;
@@ -606,7 +608,7 @@ ResultType tryBranch(INTER_FUNCTIONSIG) {
             var_list = popVarList(var_list);
 
     if (set_result)
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
     return result->type;
 }
 
@@ -616,16 +618,16 @@ ResultType breakCycle(INTER_FUNCTIONSIG){
     if (st->u.break_cycle.times == NULL)
         goto not_times;
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.break_cycle.times, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.break_cycle.times, var_list, result, belong)))
         return result->type;
 
-    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         return result->type;
     times_int = (int)result->value->value->data.num.num;
     freeResult(result);
 
     not_times:
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     if (times_int >= 0) {
         result->type = break_return;
         result->times = times_int;
@@ -638,16 +640,16 @@ ResultType continueCycle(INTER_FUNCTIONSIG){
     setResultCore(result);
     if (st->u.continue_cycle.times == NULL)
         goto not_times;
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.continue_cycle.times, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.continue_cycle.times, var_list, result, belong)))
         return result->type;
 
-    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         return result->type;
     times_int = (int)result->value->value->data.num.num;
     freeResult(result);
 
     not_times:
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     if (times_int >= 0) {
         result->type = continue_return;
         result->times = times_int;
@@ -660,16 +662,16 @@ ResultType regoIf(INTER_FUNCTIONSIG){
     setResultCore(result);
     if (st->u.rego_if.times == NULL)
         goto not_times;
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.rego_if.times, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.rego_if.times, var_list, result, belong)))
         return result->type;
 
-    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         return result->type;
     times_int = (int)result->value->value->data.num.num;
     freeResult(result);
 
     not_times:
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     if (times_int >= 0) {
         result->type = rego_return;
         result->times = times_int;
@@ -682,16 +684,16 @@ ResultType restartCode(INTER_FUNCTIONSIG){
     setResultCore(result);
     if (st->u.restart.times == NULL)
         goto not_times;
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.restart.times, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.restart.times, var_list, result, belong)))
         return result->type;
 
-    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         return result->type;
     times_int = (int)result->value->value->data.num.num;
     freeResult(result);
 
     not_times:
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     if (times_int >= 0) {
         result->type = restart_return;
         result->times = times_int;
@@ -702,11 +704,11 @@ ResultType restartCode(INTER_FUNCTIONSIG){
 ResultType returnCode(INTER_FUNCTIONSIG){
     setResultCore(result);
     if (st->u.return_code.value == NULL) {
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
         goto set_result;
     }
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.return_code.value, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.return_code.value, var_list, result, belong)))
         return result->type;
 
     set_result:
@@ -717,11 +719,11 @@ ResultType returnCode(INTER_FUNCTIONSIG){
 ResultType yieldCode(INTER_FUNCTIONSIG){
     setResultCore(result);
     if (st->u.yield_code.value == NULL) {
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
         goto set_result;
     }
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.yield_code.value, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.yield_code.value, var_list, result, belong)))
         return result->type;
 
     set_result:
@@ -732,11 +734,11 @@ ResultType yieldCode(INTER_FUNCTIONSIG){
 ResultType raiseCode(INTER_FUNCTIONSIG){
     setResultCore(result);
     if (st->u.raise_code.value == NULL) {
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
         goto set_result;
     }
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.raise_code.value, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.raise_code.value, var_list, result, belong)))
         return result->type;
 
     set_result:
@@ -747,13 +749,13 @@ ResultType raiseCode(INTER_FUNCTIONSIG){
 
 ResultType assertCode(INTER_FUNCTIONSIG){
     setResultCore(result);
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.raise_code.value, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.raise_code.value, var_list, result, belong)))
         return result->type;
 
     if (checkBool(result->value->value))
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
     else
-        setResultErrorSt(result, inter, "AssertException", "Raise by user", st, father, true);
+        setResultErrorSt(result, inter, "AssertException", "Raise by user", st, belong, true);
     return result->type;
 }
 
@@ -762,20 +764,20 @@ ResultType gotoLabel(INTER_FUNCTIONSIG){
     char *label = NULL;
     setResultCore(result);
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.goto_.label, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.goto_.label, var_list, result, belong)))
         return result->type;
-    if (!checkString(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (!checkString(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         return result->type;
     label = memStrcpy(result->value->value->data.str.str);
 
     freeResult(result);
     if (st->u.goto_.times == NULL)
         goto not_times;
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.goto_.times, var_list, result, father))) {
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.goto_.times, var_list, result, belong))) {
         memFree(label);
         return result->type;
     }
-    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, father))) {
+    if (!checkNumber(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong))) {
         memFree(label);
         return result->type;
     }
@@ -783,8 +785,8 @@ ResultType gotoLabel(INTER_FUNCTIONSIG){
     freeResult(result);
     not_times:
     if (st->u.goto_.return_ == NULL)
-        setResult(result, inter, father);
-    else if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.goto_.return_, var_list, result, father))) {
+        setResult(result, inter, belong);
+    else if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.goto_.return_, var_list, result, belong))) {
         memFree(label);
         return result->type;
     }
@@ -802,16 +804,16 @@ ResultType runLabel(INTER_FUNCTIONSIG) {
     freeResult(result);
     var_list = pushVarList(var_list, inter);
     if (st->u.label_.as != NULL)
-        assCore(st->u.label_.as, goto_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        assCore(st->u.label_.as, goto_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     gc_freeTmpLink(&goto_value->gc_status);
     if (st->u.label_.as != NULL && !run_continue(result))
         goto return_;
 
     freeResult(result);
     if (st->u.label_.command != NULL)
-        operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.label_.command, var_list, result, father));
+        operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.label_.command, var_list, result, belong));
     else
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
 
     return_:
     popVarList(var_list);

+ 36 - 36
src/runcall.c

@@ -3,33 +3,33 @@
 ResultType setClass(INTER_FUNCTIONSIG) {
     Argument *call = NULL;
     LinkValue *tmp = NULL;
-    FatherValue *class_father = NULL;
-    VarList *father_var = NULL;
+    Inherit *class_belong = NULL;
+    VarList *belong_var = NULL;
     enum FunctionPtType pt_type_bak = inter->data.default_pt_type;
     setResultCore(result);
 
-    call = getArgument(st->u.set_class.father, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    call = getArgument(st->u.set_class.father, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!run_continue(result))
         goto error_;
 
-    class_father = setFather(call);
+    class_belong = setFather(call);
     freeArgument(call, false);
-    tmp = makeLinkValue(makeClassValue(copyVarList(var_list, false, inter), inter, class_father), father, inter);
+    tmp = makeLinkValue(makeClassValue(copyVarList(var_list, false, inter), inter, class_belong), belong, inter);
     gc_addTmpLink(&tmp->gc_status);
 
-    father_var = tmp->value->object.var->next;
+    belong_var = tmp->value->object.var->next;
     tmp->value->object.var->next = var_list;
     freeResult(result);
     inter->data.default_pt_type = object_free_;
     functionSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.set_class.st, tmp->value->object.var, result, tmp));
     inter->data.default_pt_type = pt_type_bak;
-    tmp->value->object.var->next = father_var;
+    tmp->value->object.var->next = belong_var;
     if (!run_continue(result))
         goto error_;
 
     freeResult(result);
     if (st->u.set_class.decoration != NULL){
-        setDecoration(st->u.set_class.decoration, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        setDecoration(st->u.set_class.decoration, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             goto error_;
         gc_freeTmpLink(&tmp->gc_status);
@@ -38,16 +38,16 @@ ResultType setClass(INTER_FUNCTIONSIG) {
         freeResult(result);
     }
 
-    assCore(st->u.set_class.name, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    assCore(st->u.set_class.name, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (run_continue(result))
-        setResult(result, inter, father);
+        setResult(result, inter, belong);
 
     gc_freeTmpLink(&tmp->gc_status);
     return result->type;
 
     error_:
     gc_freeTmpLink(&tmp->gc_status);
-    setResultErrorSt(result, inter, NULL, NULL, st, father, false);
+    setResultErrorSt(result, inter, NULL, NULL, st, belong, false);
     return result->type;
 }
 
@@ -59,10 +59,10 @@ ResultType setFunction(INTER_FUNCTIONSIG) {
 
     function_var = copyVarList(var_list, false, inter);
     function_value = makeVMFunctionValue(st->u.set_function.function, st->u.set_function.parameter, function_var, inter);
-    tmp = makeLinkValue(function_value, father, inter);
+    tmp = makeLinkValue(function_value, belong, inter);
     gc_addTmpLink(&tmp->gc_status);
     if (st->u.set_function.decoration != NULL){
-        setDecoration(st->u.set_function.decoration, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        setDecoration(st->u.set_function.decoration, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result))
             goto error_;
         gc_freeTmpLink(&tmp->gc_status);
@@ -70,10 +70,10 @@ ResultType setFunction(INTER_FUNCTIONSIG) {
         result->value = NULL;
         freeResult(result);
     }
-    assCore(st->u.set_function.name, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    assCore(st->u.set_function.name, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!run_continue(result))
         goto error_;
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
     gc_freeTmpLink(&tmp->gc_status);
     return result->type;
 
@@ -90,7 +90,7 @@ ResultType setLambda(INTER_FUNCTIONSIG) {
     result->type = operation_return;
     function_var = copyVarList(var_list, false, inter);
     function_value = makeVMFunctionValue(st->u.base_lambda.function, st->u.base_lambda.parameter, function_var, inter);
-    result->value = makeLinkValue(function_value, father, inter);
+    result->value = makeLinkValue(function_value, belong, inter);
     gc_addTmpLink(&result->value->gc_status);
     return result->type;
 }
@@ -98,13 +98,13 @@ ResultType setLambda(INTER_FUNCTIONSIG) {
 ResultType callBack(INTER_FUNCTIONSIG) {
     LinkValue *function_value = NULL;
     setResultCore(result);
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.call_function.function, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.call_function.function, var_list, result, belong)))
         goto return_;
     function_value = result->value;
     result->value = NULL;
     freeResult(result);
 
-    callBackCorePt(function_value, st->u.call_function.parameter, st->line, st->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    callBackCorePt(function_value, st->u.call_function.parameter, st->line, st->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
 
     gc_freeTmpLink(&function_value->gc_status);
     return_:
@@ -116,12 +116,12 @@ ResultType callBackCorePt(LinkValue *function_value, Parameter *pt, long line, c
     setResultCore(result);
     gc_addTmpLink(&function_value->gc_status);
 
-    arg = getArgument(pt, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    arg = getArgument(pt, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!run_continue(result))
         goto return_;
 
     freeResult(result);
-    callBackCore(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    callBackCore(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
 
     return_:
     gc_freeTmpLink(&function_value->gc_status);
@@ -133,14 +133,14 @@ ResultType callBackCore(LinkValue *function_value, Argument *arg, long line, cha
     setResultCore(result);
     gc_addTmpLink(&function_value->gc_status);
     if (function_value->value->type == function && function_value->value->data.function.type == vm_function)
-        callVMFunction(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callVMFunction(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     else if (function_value->value->type == function && function_value->value->data.function.type == c_function)
-        callCFunction(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callCFunction(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     else if (function_value->value->type == class)
-        callClass(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callClass(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     else
-        callObject(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
-    setResultError(result, inter, NULL, NULL, line, file, father, false);
+        callObject(function_value, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    setResultError(result, inter, NULL, NULL, line, file, belong, false);
 
     gc_freeTmpLink(&function_value->gc_status);
     return result->type;
@@ -152,11 +152,11 @@ ResultType callClass(LinkValue *class_value, Argument *arg, long int line, char
 
     if (_new_ != NULL){
         gc_addTmpLink(&_new_->gc_status);
-        callBackCore(_new_, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callBackCore(_new_, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         gc_freeTmpLink(&_new_->gc_status);
     }
     else
-        setResultError(result, inter, "ClassException", "Don't find __new__", line, file, father, true);
+        setResultError(result, inter, "ClassException", "Don't find __new__", line, file, belong, true);
 
     return result->type;
 }
@@ -167,11 +167,11 @@ ResultType callObject(LinkValue *object_value, Argument *arg, long int line, cha
 
     if (_call_ != NULL){
         gc_addTmpLink(&_call_->gc_status);
-        callBackCore(_call_, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callBackCore(_call_, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         gc_freeTmpLink(&_call_->gc_status);
     }
     else
-        setResultError(result, inter, "TypeException", "Object is not callable", line, file, father, true);
+        setResultError(result, inter, "TypeException", "Object is not callable", line, file, belong, true);
 
     return result->type;
 }
@@ -183,7 +183,7 @@ ResultType callCFunction(LinkValue *function_value, Argument *arg, long int line
     setResultCore(result);
     gc_addTmpLink(&function_value->gc_status);
 
-    setFunctionArgument(&arg, function_value, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    setFunctionArgument(&arg, function_value, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!run_continue(result))
         goto return_;
 
@@ -192,7 +192,7 @@ ResultType callCFunction(LinkValue *function_value, Argument *arg, long int line
     gc_freeze(inter, var_list, function_var, true);
 
     freeResult(result);
-    of(CALL_OfficialFunction(arg, function_var, result, function_value->father));
+    of(CALL_OfficialFunction(arg, function_var, result, function_value->belong));
 
     gc_freeze(inter, var_list, function_var, false);
     freeFunctionArgument(arg, bak);
@@ -216,13 +216,13 @@ ResultType callVMFunction(LinkValue *function_value, Argument *arg, long int lin
 
     gc_freeze(inter, var_list, function_var, true);
 
-    setFunctionArgument(&arg, function_value, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    setFunctionArgument(&arg, function_value, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!run_continue(result))
         goto return_;
 
     freeResult(result);
     gc_addTmpLink(&function_var->hashtable->gc_status);
-    setParameterCore(line, file, arg, func_pt, function_var, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, function_value->father));
+    setParameterCore(line, file, arg, func_pt, function_var, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, function_value->belong));
     freeFunctionArgument(arg, bak);
     gc_freeTmpLink(&function_var->hashtable->gc_status);
     if (!run_continue(result)) {
@@ -236,7 +236,7 @@ ResultType callVMFunction(LinkValue *function_value, Argument *arg, long int lin
     }
 
     freeResult(result);
-    functionSafeInterStatement(CALL_INTER_FUNCTIONSIG(funtion_st, function_var, result, function_value->father));
+    functionSafeInterStatement(CALL_INTER_FUNCTIONSIG(funtion_st, function_var, result, function_value->belong));
     gc_freeze(inter, var_list, function_var, false);
 
     funtion_st = function_value->value->data.function.function;
@@ -266,14 +266,14 @@ ResultType setDecoration(DecorationStatement *ds, LinkValue *value, INTER_FUNCTI
     gc_addTmpLink(&value->gc_status);
     for (PASS; ds != NULL; ds = ds->next){
         freeResult(result);
-        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(ds->decoration, var_list, result, father)))
+        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(ds->decoration, var_list, result, belong)))
             break;
         pt = makeValueParameter(makeBaseLinkValueStatement(value, ds->decoration->line, ds->decoration->code_file));
         decall = result->value;
         result->value = NULL;
 
         freeResult(result);
-        callBackCorePt(decall, pt, ds->decoration->line, ds->decoration->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callBackCorePt(decall, pt, ds->decoration->line, ds->decoration->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         gc_freeTmpLink(&decall->gc_status);
         freeParameter(pt, true);
         if (!run_continue(result))

+ 22 - 22
src/runfile.c

@@ -6,11 +6,11 @@ ResultType includeFile(INTER_FUNCTIONSIG) {
     char *file_dir = NULL;
     setResultCore(result);
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.include_file.file, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.include_file.file, var_list, result, belong)))
         return result->type;
 
     if (!isType(result->value->value, string)){
-        setResultErrorSt(result, inter, "TypeException", "Don't get a string value", st, father, true);
+        setResultErrorSt(result, inter, "TypeException", "Don't get a string value", st, belong, true);
         goto return_;
     }
 
@@ -18,7 +18,7 @@ ResultType includeFile(INTER_FUNCTIONSIG) {
     freeResult(result);
 
     if (checkFile(file_dir) != 1){
-        setResultErrorSt(result, inter, "IncludeFileException", "File is not readable", st, father, true);
+        setResultErrorSt(result, inter, "IncludeFileException", "File is not readable", st, belong, true);
         goto return_;
     }
 
@@ -26,13 +26,13 @@ ResultType includeFile(INTER_FUNCTIONSIG) {
     pm = makeParserMessage(file_dir);
     parserCommandList(pm, inter, true, new_st);
     if (pm->status != success){
-        setResultErrorSt(result, inter, "IncludeSyntaxException", pm->status_message, st, father, true);
+        setResultErrorSt(result, inter, "IncludeSyntaxException", pm->status_message, st, belong, true);
         goto return_;
     }
 
-    functionSafeInterStatement(CALL_INTER_FUNCTIONSIG(new_st, var_list, result, father));
+    functionSafeInterStatement(CALL_INTER_FUNCTIONSIG(new_st, var_list, result, belong));
     if (!run_continue(result))
-        setResultErrorSt(result, inter, NULL, NULL, st, father, false);
+        setResultErrorSt(result, inter, NULL, NULL, st, belong, false);
 
     return_:
     freeStatement(new_st);
@@ -45,44 +45,44 @@ ResultType importFileCore(VarList **new_object, char **file_dir, INTER_FUNCTIONS
     ParserMessage *pm = NULL;
     Statement *run_st = NULL;
     setResultCore(result);
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         goto return_;
 
     if (!isType(result->value->value, string)) {
-        setResultErrorSt(result, inter, "TypeException", "Don't get a string value", st, father, true);
+        setResultErrorSt(result, inter, "TypeException", "Don't get a string value", st, belong, true);
         goto return_;
     }
 
     *file_dir = result->value->value->data.str.str;
     freeResult(result);
     if (checkFile(*file_dir) != 1) {
-        setResultErrorSt(result, inter, "ImportFileException", "File is not readable", st, father, true);
+        setResultErrorSt(result, inter, "ImportFileException", "File is not readable", st, belong, true);
         goto return_;
     }
 
 
-    import_inter = makeInter(NULL, father);
+    import_inter = makeInter(NULL, belong);
     pm = makeParserMessage(*file_dir);
     run_st = makeStatement(0, *file_dir);
     parserCommandList(pm, import_inter, true, run_st);
     if (pm->status != success) {
         freeInter(import_inter, false);
-        setResultErrorSt(result, inter, "ImportSyntaxException", pm->status_message, st, father, true);
+        setResultErrorSt(result, inter, "ImportSyntaxException", pm->status_message, st, belong, true);
         goto return_;
     }
 
     globalIterStatement(result, import_inter, run_st);
     if (!run_continue(result)) {
         freeInter(import_inter, false);
-        result->value = makeLinkValue(inter->base, father, inter);  // 重新设定none值
-        setResultErrorSt(result, inter, NULL, NULL, st, father, false);
+        result->value = makeLinkValue(inter->base, belong, inter);  // 重新设定none值
+        setResultErrorSt(result, inter, NULL, NULL, st, belong, false);
         goto return_;
     }
 
     *new_object = import_inter->var_list;
     import_inter->var_list = NULL;
     mergeInter(import_inter, inter);
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
 
     return_:
     freeStatement(run_st);
@@ -95,7 +95,7 @@ ResultType importFile(INTER_FUNCTIONSIG) {
     VarList *new_object = NULL;
     LinkValue *import_value = NULL;
     setResultCore(result);
-    importFileCore(&new_object, &file_dir, CALL_INTER_FUNCTIONSIG(st->u.import_file.file, var_list, result, father));
+    importFileCore(&new_object, &file_dir, CALL_INTER_FUNCTIONSIG(st->u.import_file.file, var_list, result, belong));
     if (!run_continue(result))
         goto return_;
 
@@ -103,13 +103,13 @@ ResultType importFile(INTER_FUNCTIONSIG) {
     {
         VarList *import_var = copyVarList(var_list, false, inter);
         Value *import_obj = makeObject(inter, new_object, import_var, NULL);
-        import_value = makeLinkValue(import_obj, father, inter);
+        import_value = makeLinkValue(import_obj, belong, inter);
     }
     if (st->u.import_file.as != NULL)
-        assCore(st->u.import_file.as, import_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        assCore(st->u.import_file.as, import_value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     else
-        addStrVar(splitDir(file_dir), true, import_value, father, CALL_INTER_FUNCTIONSIG_CORE(var_list));
-    setResult(result, inter, father);
+        addStrVar(splitDir(file_dir), true, import_value, belong, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+    setResult(result, inter, belong);
 
     return_:
     return result->type;
@@ -122,19 +122,19 @@ ResultType fromImportFile(INTER_FUNCTIONSIG) {
     Parameter *pt = st->u.from_import_file.pt;
     Parameter *as = st->u.from_import_file.as != NULL ? st->u.from_import_file.as : st->u.from_import_file.pt;
     setResultCore(result);
-    importFileCore(&new_object, &file_dir, CALL_INTER_FUNCTIONSIG(st->u.from_import_file.file, var_list, result, father));
+    importFileCore(&new_object, &file_dir, CALL_INTER_FUNCTIONSIG(st->u.from_import_file.file, var_list, result, belong));
     if (!run_continue(result))
         goto return_;
 
     freeResult(result);
     if (pt != NULL) {
-        setParameter(st->line, st->code_file, pt, as, var_list, father, CALL_INTER_FUNCTIONSIG_NOT_ST(new_object, result, father));
+        setParameter(st->line, st->code_file, pt, as, var_list, belong, CALL_INTER_FUNCTIONSIG_NOT_ST(new_object, result, belong));
         if (!run_continue(result))
             goto return_;
     }
     else
         updateHashTable(var_list->hashtable, new_object->hashtable, inter);
-    setResult(result, inter, father);
+    setResult(result, inter, belong);
 
     return_:
     freeVarList(new_object);

+ 43 - 43
src/runoperation.c

@@ -17,28 +17,28 @@ ResultType operationStatement(INTER_FUNCTIONSIG) {
     setResultCore(result);
     switch (st->u.operation.OperationType) {
         case OPT_ADD:
-            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, father), inter->data.object_add);
+            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong), inter->data.object_add);
             break;
         case OPT_SUB:
-            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, father), inter->data.object_sub);
+            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong), inter->data.object_sub);
             break;
         case OPT_MUL:
-            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, father), inter->data.object_mul);
+            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong), inter->data.object_mul);
             break;
         case OPT_DIV:
-            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, father), inter->data.object_div);
+            operationCore(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong), inter->data.object_div);
             break;
         case OPT_ASS:
-            assOperation(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            assOperation(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case OPT_POINT:
-            pointOperation(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            pointOperation(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         case OPT_BLOCK:
-            blockOperation(CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+            blockOperation(CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
             break;
         default:
-            setResult(result, inter, father);
+            setResult(result, inter, belong);
             break;
     }
     return result->type;
@@ -49,7 +49,7 @@ ResultType blockOperation(INTER_FUNCTIONSIG) {
     bool yield_run;
     if ((yield_run = popStatementVarList(st, &var_list, var_list, inter)))
         info_st = st->info.node;
-    blockSafeInterStatement(CALL_INTER_FUNCTIONSIG(info_st, var_list, result, father));
+    blockSafeInterStatement(CALL_INTER_FUNCTIONSIG(info_st, var_list, result, belong));
     if (result->type == error_return)
         return result->type;
     else if (yield_run) {
@@ -77,7 +77,7 @@ ResultType pointOperation(INTER_FUNCTIONSIG) {
     LinkValue *left;
     VarList *object = NULL;
     VarList *out_var = NULL;
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.left, var_list, result, father)) || result->value->value->type == none)
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.left, var_list, result, belong)) || result->value->value->type == none)
         return result->type;
     left = result->value;
 
@@ -93,13 +93,13 @@ ResultType pointOperation(INTER_FUNCTIONSIG) {
         goto return_;
     else if ((left->aut == public_aut || left->aut == auto_aut) && (result->value->aut != public_aut && result->value->aut != auto_aut))
         setResultErrorSt(result, inter, "PermissionsException", "Wrong Permissions: access variables as public", st,
-                         father, true);
+                         belong, true);
     else if ((left->aut == protect_aut) && (result->value->aut == private_aut))
         setResultErrorSt(result, inter, "PermissionsException", "Wrong Permissions: access variables as protect", st,
-                         father, true);
+                         belong, true);
 
-    if (result->value->father->value != left->value && checkAttribution(left->value, result->value->father->value))
-        result->value->father = left;
+    if (result->value->belong == NULL || result->value->belong->value != left->value && checkAttribution(left->value, result->value->belong->value))
+        result->value->belong = left;
 
     return_:
     gc_freeze(inter, var_list, object, false);
@@ -118,16 +118,16 @@ ResultType assOperation(INTER_FUNCTIONSIG) {
         function_var = copyVarList(var_list, false, inter);
         function_value = makeVMFunctionValue(st->u.operation.right, st->u.operation.left->u.call_function.parameter,
                                              function_var, inter);
-        tmp = makeLinkValue(function_value, father, inter);
-        assCore(st->u.operation.left->u.call_function.function, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        tmp = makeLinkValue(function_value, belong, inter);
+        assCore(st->u.operation.left->u.call_function.function, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     }
     else{
-        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.right, var_list, result, father)))
+        if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.right, var_list, result, belong)))
             return result->type;
         value = result->value;
 
         freeResult(result);
-        assCore(st->u.operation.left, value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        assCore(st->u.operation.left, value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     }
     return result->type;
 }
@@ -142,7 +142,7 @@ ResultType assCore(Statement *name, LinkValue *value, INTER_FUNCTIONSIG_NOT_ST){
         Statement *tmp_st = makeBaseLinkValueStatement(value, name->line, name->code_file);
 
         pt = makeArgsParameter(tmp_st);
-        call = getArgument(pt, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        call = getArgument(pt, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (!run_continue(result)) {
             freeArgument(call, false);
             freeParameter(pt, true);
@@ -150,10 +150,10 @@ ResultType assCore(Statement *name, LinkValue *value, INTER_FUNCTIONSIG_NOT_ST){
         }
 
         freeResult(result);
-        setParameterCore(name->line, name->code_file, call, name->u.base_list.list, var_list, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        setParameterCore(name->line, name->code_file, call, name->u.base_list.list, var_list, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         if (run_continue(result)){
             Argument *tmp = call;
-            LinkValue *new_value = makeLinkValue(makeListValue(&tmp, inter, value_tuple), father, inter);
+            LinkValue *new_value = makeLinkValue(makeListValue(&tmp, inter, value_tuple), belong, inter);
             freeResult(result);
             setResultOperation(result, new_value);
         }
@@ -161,12 +161,12 @@ ResultType assCore(Statement *name, LinkValue *value, INTER_FUNCTIONSIG_NOT_ST){
         freeParameter(pt, true);
     }
     else if (name->type == operation && name->u.operation.OperationType == OPT_POINT)
-        pointAss(name, value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        pointAss(name, value, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     else{
         char *str_name = NULL;
         int int_times = 0;
         LinkValue *var_value = NULL;
-        getVarInfo(&str_name, &int_times, CALL_INTER_FUNCTIONSIG(name, var_list, result, father));
+        getVarInfo(&str_name, &int_times, CALL_INTER_FUNCTIONSIG(name, var_list, result, belong));
         if (!run_continue(result)) {
             memFree(str_name);
             return result->type;
@@ -191,7 +191,7 @@ ResultType assCore(Statement *name, LinkValue *value, INTER_FUNCTIONSIG_NOT_ST){
 ResultType pointAss(Statement *name, LinkValue *value, INTER_FUNCTIONSIG_NOT_ST) {
     Result left;
     VarList *object = NULL;
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(name->u.operation.left, var_list, result, father)))
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(name->u.operation.left, var_list, result, belong)))
         return result->type;
     left = *result;
     setResultCore(result);
@@ -199,9 +199,9 @@ ResultType pointAss(Statement *name, LinkValue *value, INTER_FUNCTIONSIG_NOT_ST)
     object = left.value->value->object.var;
     gc_freeze(inter, var_list, object, true);
     if (name->u.operation.right->type == OPERATION && name->u.operation.right->u.operation.OperationType == OPT_POINT)
-        pointAss(name->u.operation.right, value, CALL_INTER_FUNCTIONSIG_NOT_ST(object, result, father));
+        pointAss(name->u.operation.right, value, CALL_INTER_FUNCTIONSIG_NOT_ST(object, result, belong));
     else
-        assCore(name->u.operation.right, value, CALL_INTER_FUNCTIONSIG_NOT_ST(object, result, father));
+        assCore(name->u.operation.right, value, CALL_INTER_FUNCTIONSIG_NOT_ST(object, result, belong));
     gc_freeze(inter, var_list, object, false);
 
     freeResult(&left);
@@ -213,7 +213,7 @@ ResultType getVar(INTER_FUNCTIONSIG, VarInfo var_info) {
     char *name = NULL;
 
     freeResult(result);
-    var_info(&name, &int_times, CALL_INTER_FUNCTIONSIG(st, var_list, result, father));
+    var_info(&name, &int_times, CALL_INTER_FUNCTIONSIG(st, var_list, result, belong));
     if (!run_continue(result)) {
         memFree(name);
         return result->type;
@@ -221,22 +221,22 @@ ResultType getVar(INTER_FUNCTIONSIG, VarInfo var_info) {
 
     freeResult(result);
     result->type = operation_return;
-    result->value = findFromVarList(name, int_times, false, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+    result->value = findFromVarList(name, int_times, 0, CALL_INTER_FUNCTIONSIG_CORE(var_list));
     if (result->value == NULL) {
         char *info = memStrcat("Name Not Found: ", name, false, false);
-        setResultErrorSt(result, inter, "NameException", info, st, father, true);
+        setResultErrorSt(result, inter, "NameException", info, st, belong, true);
         memFree(info);
     }
     else if ((st->aut == public_aut) && (result->value->aut != public_aut && result->value->aut != auto_aut)){
         setResultCore(result);
         char *info = memStrcat("Wrong Permissions: access variables as public ", name, false, false);
-        setResultErrorSt(result, inter, "PermissionsException", info, st, father, true);
+        setResultErrorSt(result, inter, "PermissionsException", info, st, belong, true);
         memFree(info);
     }
     else if ((st->aut == protect_aut) && (result->value->aut == private_aut)){
         setResultCore(result);
         char *info = memStrcat("Wrong Permissions: access variables as protect ", name, false, false);
-        setResultErrorSt(result, inter, "PermissionsException", info, st, father, true);
+        setResultErrorSt(result, inter, "PermissionsException", info, st, belong, true);
         memFree(info);
     }
     else
@@ -266,7 +266,7 @@ ResultType getBaseValue(INTER_FUNCTIONSIG) {
             value = makeNoneValue(inter);
         else
             value = makeStringValue(st->u.base_value.str, inter);
-        result->value = makeLinkValue(value, father, inter);
+        result->value = makeLinkValue(value, belong, inter);
     }
 
     result->type = operation_return;
@@ -279,14 +279,14 @@ ResultType getList(INTER_FUNCTIONSIG) {
     Argument *at_tmp = NULL;
 
     setResultCore(result);
-    at = getArgument(st->u.base_list.list, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    at = getArgument(st->u.base_list.list, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     at_tmp = at;
     if (!run_continue(result)){
         freeArgument(at_tmp, false);
         return result->type;
     }
 
-    LinkValue *value = makeLinkValue(makeListValue(&at, inter, st->u.base_list.type), father, inter);
+    LinkValue *value = makeLinkValue(makeListValue(&at, inter, st->u.base_list.type), belong, inter);
     setResultOperation(result, value);
     freeArgument(at_tmp, false);
 
@@ -298,7 +298,7 @@ ResultType getDict(INTER_FUNCTIONSIG) {
     Argument *at_tmp = NULL;
 
     setResultCore(result);
-    at = getArgument(st->u.base_dict.dict, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    at = getArgument(st->u.base_dict.dict, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     at_tmp = at;
     if (!run_continue(result)){
         freeArgument(at_tmp, false);
@@ -306,14 +306,14 @@ ResultType getDict(INTER_FUNCTIONSIG) {
     }
 
     freeResult(result);
-    Value *tmp_value = makeDictValue(&at, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    Value *tmp_value = makeDictValue(&at, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!run_continue(result)) {
         freeArgument(at_tmp, false);
         return result->type;
     }
 
     freeResult(result);
-    LinkValue *value = makeLinkValue(tmp_value, father, inter);
+    LinkValue *value = makeLinkValue(tmp_value, belong, inter);
     setResultOperation(result, value);
     freeArgument(at_tmp, false);
 
@@ -333,7 +333,7 @@ ResultType setDefault(INTER_FUNCTIONSIG){
         char *name = NULL;
         int times = 0;
         freeResult(result);
-        getVarInfo(&name, &times, CALL_INTER_FUNCTIONSIG(pt->data.value, var_list, result, father));
+        getVarInfo(&name, &times, CALL_INTER_FUNCTIONSIG(pt->data.value, var_list, result, belong));
         if (!run_continue(result))
             break;
         if (type != default_)
@@ -345,12 +345,12 @@ ResultType setDefault(INTER_FUNCTIONSIG){
 }
 
 bool getLeftRightValue(Result *left, Result *right, INTER_FUNCTIONSIG){
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.left, var_list, result, father)) || result->value->value->type == none)
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.left, var_list, result, belong)) || result->value->value->type == none)
         return true;
     *left = *result;
     setResultCore(result);
 
-    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.right, var_list, result, father)) || result->value->value->type == none)
+    if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.operation.right, var_list, result, belong)) || result->value->value->type == none)
         return true;
     *right = *result;
     setResultCore(result);
@@ -364,20 +364,20 @@ ResultType operationCore(INTER_FUNCTIONSIG, char *name) {
     setResultCore(&left);
     setResultCore(&right);
 
-    if (getLeftRightValue(&left, &right, CALL_INTER_FUNCTIONSIG(st, var_list, result, father)))
+    if (getLeftRightValue(&left, &right, CALL_INTER_FUNCTIONSIG(st, var_list, result, belong)))
         return result->type;
 
     _func_ = findAttributes(name, false, left.value, inter);
     if (_func_ != NULL){
         Argument *arg = makeValueArgument(right.value);
         gc_addTmpLink(&_func_->gc_status);
-        callBackCore(_func_, arg, st->line, st->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+        callBackCore(_func_, arg, st->line, st->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         gc_freeTmpLink(&_func_->gc_status);
         freeArgument(arg, true);
     }
     else {
         char *message = memStrcat("Don't find ", name, false, false);
-        setResultErrorSt(result, inter, "TypeException", message, st, father, true);
+        setResultErrorSt(result, inter, "TypeException", message, st, belong, true);
         memFree(message);
     }
 

+ 83 - 55
src/value.c

@@ -1,18 +1,18 @@
 #include "__run.h"
 
-Value *makeObject(Inter *inter, VarList *object, VarList *out_var, FatherValue *father) {
+Value *makeObject(Inter *inter, VarList *object, VarList *out_var, Inherit *inherit) {
     Value *tmp, *list_tmp = inter->base;
     tmp = memCalloc(1, sizeof(Value));
     setGC(&tmp->gc_status);
     tmp->type = object_;
     tmp->gc_next = NULL;
-    if (inter->data.object != NULL && father == NULL)
-        father = makeFatherValue(makeLinkValue(inter->data.object, NULL, inter));
-    if (out_var == NULL && father != NULL)
-        out_var = copyVarList(father->value->value->object.out_var, false, inter);
-    tmp->object.var = makeObjectVarList(father, inter, object);
+    if (inter->data.object != NULL && inherit == NULL)
+        inherit = makeInherit(makeLinkValue(inter->data.object, NULL, inter));
+    if (out_var == NULL && inherit != NULL)
+        out_var = copyVarList(inherit->value->value->object.out_var, false, inter);
+    tmp->object.var = makeObjectVarList(inherit, inter, object);
     tmp->object.out_var = out_var;
-    tmp->object.father = father;
+    tmp->object.inherit = inherit;
 
     if (list_tmp == NULL){
         inter->base = tmp;
@@ -41,7 +41,7 @@ Value *makeNoneValue(Inter *inter) {
 }
 
 Value *makeBoolValue(bool bool_num, Inter *inter) {
-    FatherValue *object_father = getFatherFromValue(inter->data.bool_, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.bool_, inter);
     VarList *new_var = copyVarList(inter->data.bool_->object.out_var, false, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, new_var, object_father);
@@ -51,7 +51,7 @@ Value *makeBoolValue(bool bool_num, Inter *inter) {
 }
 
 Value *makePassValue(Inter *inter){
-    FatherValue *object_father = getFatherFromValue(inter->data.pass_, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.pass_, inter);
     VarList *new_var = copyVarList(inter->data.pass_->object.out_var, false, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, new_var, object_father);
@@ -60,7 +60,7 @@ Value *makePassValue(Inter *inter){
 }
 
 Value *makeNumberValue(NUMBER_TYPE num, Inter *inter) {
-    FatherValue *object_father = getFatherFromValue(inter->data.num, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.num, inter);
     VarList *new_var = copyVarList(inter->data.num->object.out_var, false, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, new_var, object_father);
@@ -70,7 +70,7 @@ Value *makeNumberValue(NUMBER_TYPE num, Inter *inter) {
 }
 
 Value *makeStringValue(char *str, Inter *inter) {
-    FatherValue *object_father = getFatherFromValue(inter->data.str, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.str, inter);
     VarList *new_var = copyVarList(inter->data.str->object.out_var, false, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, new_var, object_father);
@@ -85,7 +85,7 @@ static void setFunctionData(Value *value, Inter *inter) {
 }
 
 Value *makeVMFunctionValue(Statement *st, Parameter *pt, VarList *var_list, Inter *inter) {
-    FatherValue *object_father = getFatherFromValue(inter->data.function, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.function, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, var_list, object_father);
     tmp->type = function;
@@ -98,7 +98,7 @@ Value *makeVMFunctionValue(Statement *st, Parameter *pt, VarList *var_list, Inte
 }
 
 Value *makeCFunctionValue(OfficialFunction of, VarList *var_list, Inter *inter) {
-    FatherValue *object_father = getFatherFromValue(inter->data.function, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.function, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, copyVarList(var_list, false, inter), object_father);
     tmp->type = function;
@@ -110,7 +110,7 @@ Value *makeCFunctionValue(OfficialFunction of, VarList *var_list, Inter *inter)
     return tmp;
 }
 
-Value *makeClassValue(VarList *var_list, Inter *inter, FatherValue *father) {
+Value *makeClassValue(VarList *var_list, Inter *inter, Inherit *father) {
     Value *tmp;
     tmp = makeObject(inter, NULL, var_list, father);
     tmp->type = class;
@@ -118,7 +118,7 @@ Value *makeClassValue(VarList *var_list, Inter *inter, FatherValue *father) {
 }
 
 Value *makeListValue(Argument **arg_ad, Inter *inter, enum ListType type) {
-    FatherValue *object_father = getFatherFromValue(inter->data.list, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.list, inter);
     VarList *new_var = copyVarList(inter->data.list->object.out_var, false, inter);
     Value *tmp;
     Argument *at = *arg_ad;
@@ -137,7 +137,7 @@ Value *makeListValue(Argument **arg_ad, Inter *inter, enum ListType type) {
 }
 
 Value *makeDictValue(Argument **arg_ad, bool new_hash, INTER_FUNCTIONSIG_NOT_ST) {
-    FatherValue *object_father = getFatherFromValue(inter->data.dict, inter);
+    Inherit *object_father = getInheritFromValue(inter->data.dict, inter);
     VarList *new_var = copyVarList(inter->data.dict->object.out_var, false, inter);
     Value *tmp;
     tmp = makeObject(inter, NULL, new_var, object_father);
@@ -148,7 +148,7 @@ Value *makeDictValue(Argument **arg_ad, bool new_hash, INTER_FUNCTIONSIG_NOT_ST)
         gc_addTmpLink(&tmp->gc_status);
         tmp->data.dict.dict = hash->hashtable;
         freeResult(result);
-        argumentToVar(arg_ad, &tmp->data.dict.size, CALL_INTER_FUNCTIONSIG_NOT_ST(hash, result, father));
+        argumentToVar(arg_ad, &tmp->data.dict.size, CALL_INTER_FUNCTIONSIG_NOT_ST(hash, result, belong));
         popVarList(hash);
         gc_freeTmpLink(&tmp->gc_status);
     }
@@ -164,7 +164,7 @@ void freeValue(Value **value) {
         PASS;
     for (VarList *tmp = free_value->object.out_var; tmp != NULL; tmp = freeVarList(tmp))
         PASS;
-    for (struct FatherValue *tmp = free_value->object.father; tmp != NULL; tmp = freeFatherValue(tmp))
+    for (struct Inherit *tmp = free_value->object.inherit; tmp != NULL; tmp = freeInherit(tmp))
         PASS;
     switch (free_value->type) {
         case string:
@@ -190,13 +190,13 @@ void freeValue(Value **value) {
     return_: return;
 }
 
-LinkValue *makeLinkValue(Value *value, LinkValue *linkValue, Inter *inter){
+LinkValue *makeLinkValue(Value *value, LinkValue *belong, Inter *inter){
     LinkValue *tmp;
     LinkValue *list_tmp = inter->link_base;
     tmp = memCalloc(1, sizeof(Value));
-    setGC(&tmp->gc_status);
-    tmp->father = linkValue;
+    tmp->belong = belong;
     tmp->value = value;
+    setGC(&tmp->gc_status);
     if (list_tmp == NULL){
         inter->link_base = tmp;
         tmp->gc_last = NULL;
@@ -230,7 +230,7 @@ LinkValue *copyLinkValue(LinkValue *value, Inter *inter) {
     LinkValue *tmp = NULL;
     if (value == NULL)
         return NULL;
-    tmp = makeLinkValue(value->value, value->father, inter);
+    tmp = makeLinkValue(value->value, value->belong, inter);
     tmp->aut = value->aut;
     return tmp;
 }
@@ -244,26 +244,26 @@ void setResultCore(Result *ru) {
     ru->node = NULL;
 }
 
-void setResult(Result *ru, Inter *inter, LinkValue *father) {
+void setResult(Result *ru, Inter *inter, LinkValue *belong) {
     freeResult(ru);
-    setResultBase(ru, inter, father);
+    setResultBase(ru, inter, belong);
 }
 
-void setResultBase(Result *ru, Inter *inter, LinkValue *father) {
+void setResultBase(Result *ru, Inter *inter, LinkValue *belong) {
     setResultCore(ru);
-    ru->value = makeLinkValue(makeNoneValue(inter), father, inter);
+    ru->value = makeLinkValue(makeNoneValue(inter), belong, inter);
     gc_addTmpLink(&ru->value->gc_status);
 }
 
-void setResultErrorSt(Result *ru, Inter *inter, char *error_type, char *error_message, Statement *st, LinkValue *father, bool new) {
-    setResultError(ru, inter, error_type, error_message, st->line, st->code_file, father, new);
+void setResultErrorSt(Result *ru, Inter *inter, char *error_type, char *error_message, Statement *st, LinkValue *belong, bool new) {
+    setResultError(ru, inter, error_type, error_message, st->line, st->code_file, belong, new);
 }
 
-void setResultError(Result *ru, Inter *inter, char *error_type, char *error_message, long int line, char *file, LinkValue *father, bool new) {
+void setResultError(Result *ru, Inter *inter, char *error_type, char *error_message, long int line, char *file, LinkValue *belong, bool new) {
     if (!new && ru->type != error_return)
         return;
     if (new) {
-        setResult(ru, inter, father);
+        setResult(ru, inter, belong);
         ru->type = error_return;
     }
     else{
@@ -273,8 +273,8 @@ void setResultError(Result *ru, Inter *inter, char *error_type, char *error_mess
     ru->error = connectError(makeError(error_type, error_message, line, file), ru->error);
 }
 
-void setResultOperationNone(Result *ru, Inter *inter, LinkValue *father) {
-    setResult(ru, inter, father);
+void setResultOperationNone(Result *ru, Inter *inter, LinkValue *belong) {
+    setResult(ru, inter, belong);
     ru->type = operation_return;
 }
 
@@ -370,7 +370,7 @@ void printValue(Value *value, FILE *debug, bool print_father) {
     fprintf(debug, "(");
     printf("<%p>", value);
     if (print_father)
-        for (FatherValue *fv = value->object.father; fv != NULL; fv = fv->next) {
+        for (Inherit *fv = value->object.inherit; fv != NULL; fv = fv->next) {
             printf(" -> ");
             printValue(fv->value->value, debug, false);
         }
@@ -382,8 +382,8 @@ void printLinkValue(LinkValue *value, char *first, char *last, FILE *debug){
     if (value == NULL)
         return;
     fprintf(debug, "%s", first);
-    if (value->father != NULL) {
-        printLinkValue(value->father, "", "", debug);
+    if (value->belong != NULL) {
+        printLinkValue(value->belong, "", "", debug);
         fprintf(debug, " . ", NULL);
     }
     if (value->value != NULL)
@@ -433,61 +433,61 @@ inline bool isType(Value *value, enum ValueType type){
     return value->type == type;
 }
 
-FatherValue *makeFatherValue(LinkValue *value){
-    FatherValue *tmp;
-    tmp = memCalloc(1, sizeof(FatherValue));
+Inherit *makeInherit(LinkValue *value){
+    Inherit *tmp;
+    tmp = memCalloc(1, sizeof(Inherit));
     tmp->value = value;
     tmp->next = NULL;
     return tmp;
 }
 
-FatherValue *copyFatherValueCore(FatherValue *value){
-    FatherValue *tmp;
+Inherit *copyInheritCore(Inherit *value){
+    Inherit *tmp;
     if (value == NULL)
         return NULL;
-    tmp = makeFatherValue(value->value);
+    tmp = makeInherit(value->value);
     return tmp;
 }
 
-FatherValue *copyFatherValue(FatherValue *value){
-    FatherValue *base = NULL;
-    FatherValue **tmp = &base;
+Inherit *copyInherit(Inherit *value){
+    Inherit *base = NULL;
+    Inherit **tmp = &base;
     for (PASS; value != NULL; value = value->next, tmp = &(*tmp)->next)
-        *tmp = copyFatherValueCore(value);
+        *tmp = copyInheritCore(value);
     return base;
 }
 
-FatherValue *freeFatherValue(FatherValue *value){
+Inherit *freeInherit(Inherit *value){
     freeBase(value, error_);
-    FatherValue *next = value->next;
+    Inherit *next = value->next;
     memFree(value);
     return next;
     error_: return NULL;
 }
 
-FatherValue *connectFatherValue(FatherValue *base, FatherValue *back){
-    FatherValue **tmp = &base;
+Inherit *connectInherit(Inherit *base, Inherit *back){
+    Inherit **tmp = &base;
     for (PASS; *tmp != NULL; tmp = &(*tmp)->next)
         PASS;
     *tmp = back;
     return base;
 }
 
-FatherValue *connectSafeFatherValue(FatherValue *base, FatherValue *back){
-    FatherValue **last_node = &base;
+Inherit *connectSafeInherit(Inherit *base, Inherit *back){
+    Inherit **last_node = &base;
     if (back == NULL)
         goto reutrn_;
     for (PASS; *last_node != NULL;)
         if ((*last_node)->value->value == back->value->value)
-            *last_node = freeFatherValue(*last_node);
+            *last_node = freeInherit(*last_node);
         else
             last_node = &(*last_node)->next;
     *last_node = back;
     reutrn_: return base;
 }
 
-FatherValue *getFatherFromValue(Value *value, Inter *inter){
-    FatherValue *object_father = NULL;
+Inherit *getInheritFromValue(Value *value, Inter *inter){  // TODO-szh set clas 和 __new__ 应用此函数
+    Inherit *object_father = NULL;
     LinkValue *num_father = makeLinkValue(value, inter->base_father, inter);
     Argument *father_arg = makeValueArgument(num_father);
     gc_addTmpLink(&num_father->gc_status);
@@ -497,6 +497,34 @@ FatherValue *getFatherFromValue(Value *value, Inter *inter){
     return object_father;
 }
 
+bool needDel(Value *object_value, Inter *inter) {
+    LinkValue *_del_ = checkStrVar("__del__", false, CALL_INTER_FUNCTIONSIG_CORE(object_value->object.var));
+    enum FunctionPtType type;
+    if (_del_ == NULL)
+        return false;
+    type = _del_->value->data.function.function_data.pt_type;
+    if ((type == object_free_ || type == object_static_) && object_value->type == class)
+        return false;
+    if (_del_->belong == NULL || _del_->belong->value == object_value || checkAttribution(object_value, _del_->belong->value))
+        return true;
+    return false;
+}
+
+bool callDel(Value *object_value, Result *result, Inter *inter, VarList *var_list) {
+    LinkValue *_del_ = findStrVar("__del__", false, CALL_INTER_FUNCTIONSIG_CORE(object_value->object.var));
+    setResultCore(result);
+
+    if (_del_ != NULL){
+        gc_addTmpLink(&_del_->gc_status);
+        if (_del_->belong == NULL || _del_->belong->value != object_value && checkAttribution(object_value, _del_->belong->value))
+            _del_->belong = makeLinkValue(object_value, inter->base_father, inter);
+        callBackCore(_del_, NULL, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, inter->base_father));
+        gc_freeTmpLink(&_del_->gc_status);
+        return true;
+    } else
+        return false;
+}
+
 /**
  * 检查 father 是否为 self 的父亲
  * @param self
@@ -504,7 +532,7 @@ FatherValue *getFatherFromValue(Value *value, Inter *inter){
  * @return
  */
 bool checkAttribution(Value *self, Value *father){
-    for (FatherValue *self_father = self->object.father; self_father != NULL; self_father = self_father->next)
+    for (Inherit *self_father = self->object.inherit; self_father != NULL; self_father = self_father->next)
         if (self_father->value->value == father)
             return true;
     return false;

+ 16 - 20
src/var.c

@@ -156,7 +156,7 @@ void addVarCore(Var **base, char *name, LinkValue *value, LinkValue *name_, Inte
             break;
         } else if (eqString((*base)->name, name)) {
             (*base)->value->value = value->value;
-            (*base)->value->father = value->father;
+            (*base)->value->belong = value->belong;
             break;
         }
     }
@@ -174,14 +174,14 @@ void updateHashTable(HashTable *update, HashTable *new, Inter *inter) {
 }
 
 
-LinkValue *findVar(char *name, bool del_var, INTER_FUNCTIONSIG_CORE) {
+LinkValue *findVar(char *name, int operating, INTER_FUNCTIONSIG_CORE) {  // TODO-szh int operating 使用枚举体
     LinkValue *tmp = NULL;
     HASH_INDEX index = time33(name);
 
     for (Var **base = &var_list->hashtable->hashtable[index]; *base != NULL; base = &(*base)->next){
         if (eqString((*base)->name, name)){
             tmp = (*base)->value;
-            if (del_var) {
+            if (operating == 1) {
                 Var *next = (*base)->next;
                 (*base)->next = NULL;
                 *base = next;
@@ -190,19 +190,27 @@ LinkValue *findVar(char *name, bool del_var, INTER_FUNCTIONSIG_CORE) {
         }
     }
     return_:
-    return copyLinkValue(tmp, inter);
+    return operating == 2 ? tmp : copyLinkValue(tmp, inter);
 }
 
-LinkValue *findFromVarList(char *name, NUMBER_TYPE times, bool del_var, INTER_FUNCTIONSIG_CORE) {
+/**
+ * @param name
+ * @param times
+ * @param operating 1-删除  2-读取  0-获取
+ * @param inter
+ * @param var_list
+ * @return
+ */
+LinkValue *findFromVarList(char *name, NUMBER_TYPE times, int operating, INTER_FUNCTIONSIG_CORE) {
     LinkValue *tmp = NULL;
     NUMBER_TYPE base = findDefault(var_list->default_var, name) + times;
     for (NUMBER_TYPE i = 0; i < base && var_list->next != NULL; i++)
         var_list = var_list->next;
-    if (del_var && var_list != NULL)
+    if (operating == 1 && var_list != NULL)
         tmp = findVar(name, true, CALL_INTER_FUNCTIONSIG_CORE(var_list));
     else
         for (PASS; var_list != NULL && tmp == NULL; var_list = var_list->next)
-            tmp = findVar(name, false, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+            tmp = findVar(name, operating, CALL_INTER_FUNCTIONSIG_CORE(var_list));
     return tmp;
 }
 
@@ -256,19 +264,7 @@ bool comparVarList(VarList *dest, VarList *src) {
     return false;
 }
 
-VarList *connectSafeVarListBack(VarList *base, VarList *back){
-    VarList **last_node = &base;
-    for (PASS; *last_node != NULL; ){
-        if ((*last_node)->hashtable == back->hashtable)
-            *last_node = freeVarList(*last_node);
-        else
-            last_node = &(*last_node)->next;
-    }
-    *last_node = back;
-    return base;
-}
-
-VarList *makeObjectVarList(FatherValue *value, Inter *inter, VarList *base) {
+VarList *makeObjectVarList(Inherit *value, Inter *inter, VarList *base) {
     VarList *tmp = base == NULL ? makeVarList(inter, true) : base;
     for (PASS; value != NULL; value = value->next) {
         VarList *new = copyVarList(value->value->value->object.var, false, inter);