Browse Source

refactor: 调整Inter中data

inter中的data保存为LinkValue的形式
减小了makeLinkValue的开销
调整了Value的构造顺序
修复function的__new__函数belong错误的问题

link #4
SongZihuan 4 years ago
parent
commit
65ad2a5986

+ 32 - 32
VirtulMathCore/include/inter.h

@@ -19,40 +19,40 @@ struct Inter{
         bool is_stderr;
         bool is_stdin;
 
-        struct Value *object;
-        struct Value *vobject;
-        struct Value *num;
-        struct Value *str;
-        struct Value *bool_;
-        struct Value *pass_;
-        struct Value *tuple;
-        struct Value *list;
-        struct Value *dict;
-        struct Value *function;
-        struct Value *none;
-        struct Value *list_iter;
-        struct Value *dict_iter;
+        struct LinkValue *object;
+        struct LinkValue *vobject;
+        struct LinkValue *num;
+        struct LinkValue *str;
+        struct LinkValue *bool_;
+        struct LinkValue *pass_;
+        struct LinkValue *tuple;
+        struct LinkValue *list;
+        struct LinkValue *dict;
+        struct LinkValue *function;
+        struct LinkValue *none;
+        struct LinkValue *list_iter;
+        struct LinkValue *dict_iter;
 
-        struct Value *base_exc;
-        struct Value *sys_exc;
-        struct Value *keyInterrupt_exc;
-        struct Value *quit_exc;
-        struct Value *exc;
-        struct Value *type_exc;
-        struct Value *arg_exc;
-        struct Value *per_exc;
-        struct Value *name_exc;
-        struct Value *goto_exc;
-        struct Value *result_exc;
-        struct Value *assert_exc;
+        struct LinkValue *base_exc;
+        struct LinkValue *sys_exc;
+        struct LinkValue *keyInterrupt_exc;
+        struct LinkValue *quit_exc;
+        struct LinkValue *exc;
+        struct LinkValue *type_exc;
+        struct LinkValue *arg_exc;
+        struct LinkValue *per_exc;
+        struct LinkValue *name_exc;
+        struct LinkValue *goto_exc;
+        struct LinkValue *result_exc;
+        struct LinkValue *assert_exc;
 
-        struct Value *key_exc;
-        struct Value *index_exc;
-        struct Value *stride_exc;
-        struct Value *super_exc;
-        struct Value *iterstop_exc;
-        struct Value *import_exc;
-        struct Value *include_exp;
+        struct LinkValue *key_exc;
+        struct LinkValue *index_exc;
+        struct LinkValue *stride_exc;
+        struct LinkValue *super_exc;
+        struct LinkValue *iterstop_exc;
+        struct LinkValue *import_exc;
+        struct LinkValue *include_exp;
 
         char *var_str_prefix;
         char *var_num_prefix;

+ 0 - 1
VirtulMathCore/include/value.h

@@ -214,7 +214,6 @@ Inherit *connectSafeInherit(Inherit *base, Inherit *back);
 bool checkAttribution(Value *self, Value *father);
 
 Inherit *getInheritFromValueCore(LinkValue *num_father);
-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

+ 4 - 0
VirtulMathCore/ofunc/include/__ofunc.h

@@ -13,6 +13,10 @@ bool iterClassFunc(NameFunc *list, INTER_FUNCTIONSIG_NOT_ST);
 void iterBaseNameFunc(NameFunc *list, struct LinkValue *father, INTER_FUNCTIONSIG_CORE);
 void iterBaseClassFunc(NameFunc *list, LinkValue *father, INTER_FUNCTIONSIG_CORE);
 Value *makeBaseChildClass(Value *inherit, Inter *inter);
+Value *makeBaseChildClass2(LinkValue *inherit, Inter *inter);
+LinkValue *makeBaseChildClass3(Value *inherit, Inter *inter);
+LinkValue *makeBaseChildClass4(LinkValue *inherit, Inter *inter);
+
 bool checkIndex(vnum *index, const vnum *size, INTER_FUNCTIONSIG_NOT_ST);
 bool checkSlice(vnum *first, vnum *second, const vnum *stride, vnum size, INTER_FUNCTIONSIG_NOT_ST);
 void addBaseClassVar(char *name, LinkValue *obj, LinkValue *belong, Inter *inter);

+ 1 - 1
VirtulMathCore/ofunc/include/object.h

@@ -1,5 +1,5 @@
 #ifndef VIRTUALMATH_OBJECT_H
 #define VIRTUALMATH_OBJECT_H
 void registeredObject(REGISTERED_FUNCTIONSIG);
-void makeBaseObject(Inter *inter);
+void makeBaseObject(Inter *inter, LinkValue *belong);
 #endif //VIRTUALMATH_OBJECT_H

+ 46 - 3
VirtulMathCore/ofunc/src/__ofunc.c

@@ -69,7 +69,7 @@ void iterBaseClassFunc(NameFunc *list, LinkValue *father, INTER_FUNCTIONSIG_CORE
 
 Value *makeBaseChildClass(Value *inherit, Inter *inter) {
     Inherit *father_value = NULL;
-    Value *num = NULL;
+    Value *new = NULL;
     {
         LinkValue *father_ = makeLinkValue(inherit, inter->base_father, inter);
         Argument *arg = makeValueArgument(father_);
@@ -78,8 +78,51 @@ Value *makeBaseChildClass(Value *inherit, Inter *inter) {
         freeArgument(arg, true);
         gc_freeTmpLink(&father_->gc_status);
     }
-    num = makeClassValue(inter->var_list, inter, father_value);
-    return num;
+    new = makeClassValue(inter->var_list, inter, father_value);
+    return new;
+}
+
+Value *makeBaseChildClass2(LinkValue *inherit, Inter *inter) {
+    Inherit *father_value = NULL;
+    Value *new = NULL;
+    {
+        Argument *arg = makeValueArgument(inherit);
+        gc_addTmpLink(&inherit->gc_status);
+        father_value = setFather(arg);
+        freeArgument(arg, true);
+        gc_freeTmpLink(&inherit->gc_status);
+    }
+    new = makeClassValue(inter->var_list, inter, father_value);
+    return new;
+}
+
+LinkValue *makeBaseChildClass3(Value *inherit, Inter *inter) {
+    Inherit *father_value = NULL;
+    Value *new = NULL;
+    {
+        LinkValue *father_ = makeLinkValue(inherit, inter->base_father, inter);
+        Argument *arg = makeValueArgument(father_);
+        gc_addTmpLink(&father_->gc_status);
+        father_value = setFather(arg);
+        freeArgument(arg, true);
+        gc_freeTmpLink(&father_->gc_status);
+    }
+    new = makeClassValue(inter->var_list, inter, father_value);
+    return makeLinkValue(new, inter->base_father, inter);
+}
+
+LinkValue *makeBaseChildClass4(LinkValue *inherit, Inter *inter) {  // TODO-szh 最终函数
+    Inherit *father_value = NULL;
+    Value *new = NULL;
+    {
+        Argument *arg = makeValueArgument(inherit);
+        gc_addTmpLink(&inherit->gc_status);
+        father_value = setFather(arg);
+        freeArgument(arg, true);
+        gc_freeTmpLink(&inherit->gc_status);
+    }
+    new = makeClassValue(inter->var_list, inter, father_value);
+    return makeLinkValue(new, inter->base_father, inter);
 }
 
 bool checkIndex(vnum *index, const vnum *size, INTER_FUNCTIONSIG_NOT_ST){

+ 2 - 2
VirtulMathCore/ofunc/src/bool.c

@@ -51,7 +51,7 @@ ResultType bool_init(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredBool(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.bool_, inter->base_father, inter);
+    LinkValue *object = inter->data.bool_;
     NameFunc tmp[] = {{inter->data.object_new, bool_new, class_free_},
                       {inter->data.object_init, bool_init, object_free_},
                       {NULL, NULL}};
@@ -62,7 +62,7 @@ void registeredBool(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseBool(Inter *inter){
-    Value *bool_ = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *bool_ = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&bool_->gc_status);
     inter->data.bool_ = bool_;
 }

+ 3 - 6
VirtulMathCore/ofunc/src/dict.c

@@ -164,10 +164,7 @@ ResultType dict_iter(OFFICAL_FUNCTIONSIG){
     }
     {
         Argument *dict_iter_arg = makeValueArgument(ap[0].value);
-        LinkValue *iter_dict = makeLinkValue(inter->data.dict_iter, inter->base_father, inter);
-        gc_addTmpLink(&iter_dict->gc_status);
-        callBackCore(iter_dict, dict_iter_arg, 0, "dict", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
-        gc_freeTmpLink(&iter_dict->gc_status);
+        callBackCore(inter->data.dict_iter, dict_iter_arg, 0, "dict", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         freeArgument(dict_iter_arg, true);
     }
     return result->type;
@@ -253,7 +250,7 @@ ResultType dict_str(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredDict(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.dict, inter->base_father, inter);
+    LinkValue *object = inter->data.dict;
     NameFunc tmp[] = {{"keys", dict_keys, object_free_},
                       {inter->data.object_new, dict_new, class_free_},
                       {inter->data.object_down, dict_down, object_free_},
@@ -270,7 +267,7 @@ void registeredDict(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseDict(Inter *inter){
-    Value *dict = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *dict = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&dict->gc_status);
     inter->data.dict = dict;
 }

+ 3 - 3
VirtulMathCore/ofunc/src/dictiter.c

@@ -35,7 +35,7 @@ ResultType dictiter_init(OFFICAL_FUNCTIONSIG){
         list = result->value;
         result->value = NULL;
 
-        listiter_class = makeLinkValue(inter->data.list_iter, inter->base_father, inter);
+        listiter_class = inter->data.list_iter;
         gc_addTmpLink(&listiter_class->gc_status);
 
         list_arg = makeValueArgument(list);
@@ -111,7 +111,7 @@ ResultType dictiter_down(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredDictIter(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.dict_iter, inter->base_father, inter);
+    LinkValue *object = inter->data.dict_iter;
     NameFunc tmp[] = {{inter->data.object_init, dictiter_init, object_free_},
                       {inter->data.object_next, dictiter_next, object_free_},
                       {inter->data.object_down, dictiter_down, object_free_},
@@ -123,7 +123,7 @@ void registeredDictIter(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseDictIter(Inter *inter){
-    Value *dict_iter = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *dict_iter = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&dict_iter->gc_status);
     inter->data.dict_iter = dict_iter;
 }

+ 5 - 5
VirtulMathCore/ofunc/src/error_.c

@@ -1,8 +1,8 @@
 #include "__ofunc.h"
 
 
-static Value *makeException(Value *father, Inter *inter){
-    Value *exc = makeBaseChildClass(father, inter);
+static LinkValue *makeException(LinkValue *father, Inter *inter){
+    LinkValue *exc = makeBaseChildClass4(father, inter);
     gc_addStatementLink(&exc->gc_status);
     return exc;
 }
@@ -24,7 +24,7 @@ ResultType base_exception_init(OFFICAL_FUNCTIONSIG){
 void registeredExcIter(REGISTERED_FUNCTIONSIG){
     struct {
         char *name;
-        Value *value;
+        LinkValue *value;
     } setList[] = {{"Exception", inter->data.exc},
                    {"SystemException", inter->data.sys_exc},
                    {"KeyboardInterrupt", inter->data.keyInterrupt_exc},
@@ -45,7 +45,7 @@ void registeredExcIter(REGISTERED_FUNCTIONSIG){
                    {"SuperException", inter->data.super_exc},
                    {NULL, NULL}};
     {
-        LinkValue *object = makeLinkValue(inter->data.base_exc, inter->base_father, inter);
+        LinkValue *object = inter->data.base_exc;
         NameFunc tmp[] = {{"__init__", base_exception_init, object_free_},
                           {NULL, NULL}};
         gc_addTmpLink(&object->gc_status);
@@ -54,7 +54,7 @@ void registeredExcIter(REGISTERED_FUNCTIONSIG){
         gc_freeTmpLink(&object->gc_status);
     }
     for (int i=0; setList[i].name != NULL; i++)
-        addBaseClassVar(setList[i].name, makeLinkValue(setList[i].value, inter->base_father, inter), belong, inter);
+        addBaseClassVar(setList[i].name, setList[i].value, belong, inter);
 }
 
 void makeExcIter(Inter *inter){

+ 5 - 5
VirtulMathCore/ofunc/src/function.c

@@ -17,7 +17,7 @@ ResultType function_new(OFFICAL_FUNCTIONSIG){
     }
 
     {
-        Inherit *object_father = getInheritFromValue(inter->data.function, inter);
+        Inherit *object_father = getInheritFromValueCore(inter->data.function);
         VarList *new_var = copyVarList(var_list, false, inter);
         Value *new_object = makeObject(inter, NULL, new_var, object_father);
         value = makeLinkValue(new_object, belong, inter);
@@ -58,7 +58,7 @@ ResultType function_init(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredFunction(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.function, inter->base_father, inter);
+    LinkValue *object = inter->data.function;
     NameFunc tmp[] = {{NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar("function", object, belong, inter);
@@ -67,14 +67,14 @@ void registeredFunction(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseFunction(Inter *inter){
-    Value *function = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *function = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&function->gc_status);
     inter->data.function = function;
 }
 
 void functionPresetting(LinkValue *func, LinkValue **func_new, LinkValue **func_init, Inter *inter) {
-    *func_new = makeCFunctionFromOf(function_new, func, function_new, function_init, inter->base_father, inter->var_list, inter);
-    *func_init = makeCFunctionFromOf(function_init, func, function_new, function_init, inter->base_father, inter->var_list, inter);
+    *func_new = makeCFunctionFromOf(function_new, func, function_new, function_init, func, inter->var_list, inter);
+    *func_init = makeCFunctionFromOf(function_init, func, function_new, function_init, func, inter->var_list, inter);
     (*func_new)->value->data.function.function_data.pt_type = class_free_;
     (*func_init)->value->data.function.function_data.pt_type = object_free_;
 }

+ 5 - 8
VirtulMathCore/ofunc/src/list.c

@@ -342,10 +342,7 @@ ResultType list_iter(OFFICAL_FUNCTIONSIG){
     }
     {
         Argument *list_iter_arg = makeValueArgument(ap[0].value);
-        LinkValue *iter_list = makeLinkValue(inter->data.list_iter, inter->base_father, inter);
-        gc_addTmpLink(&iter_list->gc_status);
-        callBackCore(iter_list, list_iter_arg, 0, "list", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
-        gc_freeTmpLink(&iter_list->gc_status);
+        callBackCore(inter->data.list_iter, list_iter_arg, 0, "list", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
         freeArgument(list_iter_arg, true);
     }
     return result->type;
@@ -428,7 +425,7 @@ ResultType list_str(OFFICAL_FUNCTIONSIG){
 
 void registeredList(REGISTERED_FUNCTIONSIG){
     {
-        LinkValue *object = makeLinkValue(inter->data.tuple, inter->base_father, inter);
+        LinkValue *object = inter->data.tuple;
         NameFunc tmp[] = {{inter->data.object_new, tuple_new, class_free_},
                           {inter->data.object_down, list_down, object_free_},
                           {inter->data.object_slice, list_slice, object_free_},
@@ -445,7 +442,7 @@ void registeredList(REGISTERED_FUNCTIONSIG){
     }
 
     {
-        LinkValue *object = makeLinkValue(inter->data.list, inter->base_father, inter);
+        LinkValue *object = inter->data.list;
         NameFunc tmp[] = {{inter->data.object_new, list_new, class_free_},
                           {inter->data.object_down_assignment, list_down_assignment, object_free_},
                           {inter->data.object_slice_assignment, list_slice_assignment, object_free_},
@@ -458,8 +455,8 @@ void registeredList(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseList(Inter *inter){
-    Value *tuple = makeBaseChildClass(inter->data.vobject, inter);
-    Value *list = makeBaseChildClass(tuple, inter);
+    LinkValue *tuple = makeBaseChildClass4(inter->data.vobject, inter);
+    LinkValue *list = makeBaseChildClass4(tuple, inter);
     gc_addStatementLink(&tuple->gc_status);
     gc_addStatementLink(&list->gc_status);
     inter->data.tuple = tuple;

+ 2 - 2
VirtulMathCore/ofunc/src/listiter.c

@@ -64,7 +64,7 @@ ResultType listiter_next(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredListIter(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.list_iter, inter->base_father, inter);
+    LinkValue *object = inter->data.list_iter;
     NameFunc tmp[] = {{inter->data.object_init, listiter_init, object_free_},
                       {inter->data.object_next, listiter_next, object_free_},
                       {NULL, NULL}};
@@ -75,7 +75,7 @@ void registeredListIter(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseListIter(Inter *inter){
-    Value *list_iter = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *list_iter = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&list_iter->gc_status);
     inter->data.list_iter = list_iter;
 }

+ 2 - 2
VirtulMathCore/ofunc/src/num.c

@@ -65,7 +65,7 @@ ResultType num_init(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredNum(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.num, inter->base_father, inter);
+    LinkValue *object = inter->data.num;
     NameFunc tmp[] = {{inter->data.object_new, num_new, class_free_},
                       {inter->data.object_init, num_init, object_free_},
                       {NULL, NULL}};
@@ -76,7 +76,7 @@ void registeredNum(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseNum(Inter *inter){
-    Value *num = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *num = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&num->gc_status);
     inter->data.num = num;
 }

+ 32 - 4
VirtulMathCore/ofunc/src/object.c

@@ -71,7 +71,7 @@ ResultType object_str(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredObject(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.object, inter->base_father, inter);
+    LinkValue *object = inter->data.object;
     NameFunc tmp[] = {{inter->data.object_new,  object_new,  class_free_},
                       {inter->data.object_repo, object_repo, all_free_},
                       {inter->data.object_str,  object_str,  all_free_},
@@ -82,8 +82,36 @@ void registeredObject(REGISTERED_FUNCTIONSIG){
     gc_freeTmpLink(&object->gc_status);
 }
 
-void makeBaseObject(Inter *inter){
+void makeBaseObject(Inter *inter, LinkValue *belong){
+    LinkValue *g_belong;
     Value *object = makeClassValue(inter->var_list, inter, NULL);
-    gc_addStatementLink(&object->gc_status);
-    inter->data.object = object;
+
+    {
+        Value *global_belong = makeObject(inter, copyVarList(inter->var_list, false, inter), NULL, NULL);
+        g_belong = makeLinkValue(global_belong, belong, inter);
+        inter->base_father = g_belong;
+        gc_addStatementLink(&inter->base_father->gc_status);
+    }
+
+    inter->data.object = makeLinkValue(object, g_belong, inter);
+    gc_addStatementLink(&inter->data.object->gc_status);
+    for (Inherit *ih=g_belong->value->object.inherit; ih != NULL; ih = ih->next) {
+        if (ih->value->value == object)
+            ih->value->belong = g_belong;
+    }
+
+
+    // TODO-szh base father在这里设置
+    {
+        Result result;
+        Argument *arg = makeValueArgument(makeLinkValue(object, g_belong, inter));
+        setResultCore(&result);
+        object_new(CALL_OFFICAL_FUNCTION(arg, inter->var_list, &result, g_belong));
+
+        inter->data.none = result.value;
+        gc_addStatementLink(&inter->data.none->gc_status);
+
+        freeArgument(arg, true);
+        freeResult(&result);
+    }
 }

+ 2 - 2
VirtulMathCore/ofunc/src/pass.c

@@ -25,7 +25,7 @@ ResultType pass_new(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredEllipisis(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.pass_, inter->base_father, inter);
+    LinkValue *object = inter->data.pass_;
     NameFunc tmp[] = {{inter->data.object_new, pass_new, class_free_},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
@@ -35,7 +35,7 @@ void registeredEllipisis(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseEllipisis(Inter *inter){
-    Value *pass_ = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *pass_ = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&pass_->gc_status);
     inter->data.pass_ = pass_;
 }

+ 7 - 8
VirtulMathCore/ofunc/src/str.c

@@ -187,7 +187,7 @@ ResultType str_iter(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredStr(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.str, inter->base_father, inter);
+    LinkValue *object = inter->data.str;
     NameFunc tmp[] = {{"to_list", str_to_list, object_free_},
                       {inter->data.object_iter, str_iter, object_free_},
                       {inter->data.object_down, str_down, object_free_},
@@ -238,8 +238,7 @@ LinkValue *makeFunctionFromValue(LinkValue *func, LinkValue *new, LinkValue *ini
 }
 
 void strFunctionPresetting(LinkValue *func, LinkValue *func_new, LinkValue *func_init, Inter *inter) {
-    Value *str = inter->data.str;
-    LinkValue *obj = makeLinkValue(str, inter->base_father, inter);
+    LinkValue *obj = inter->data.str;
 
     LinkValue *new_func = NULL;
     LinkValue *new_name = NULL;
@@ -249,17 +248,17 @@ void strFunctionPresetting(LinkValue *func, LinkValue *func_new, LinkValue *func
     LinkValue *init_name = NULL;
     char *init_name_ = setStrVarName(inter->data.object_init, false, inter);
 
-    new_func = makeFunctionFromValue(func, func_new, func_init, str_new, obj, str->object.var, inter);
+    new_func = makeFunctionFromValue(func, func_new, func_init, str_new, obj, obj->value->object.var, inter);
     new_func->value->data.function.function_data.pt_type = class_free_;
-    init_func = makeFunctionFromValue(func, func_new, func_init, str_init, obj, str->object.var, inter);
+    init_func = makeFunctionFromValue(func, func_new, func_init, str_init, obj, obj->value->object.var, inter);
     init_func->value->data.function.function_data.pt_type = object_free_;
 
 
     new_name = makeStrFromOf(obj, new_func, init_func, inter->data.object_new, inter);
     init_name = makeStrFromOf(obj, new_func, init_func, inter->data.object_init, inter);
 
-    addFromVarList(new_name_, new_name, 0, new_func, CALL_INTER_FUNCTIONSIG_CORE(str->object.var));
-    addFromVarList(init_name_, init_name, 0, init_func, CALL_INTER_FUNCTIONSIG_CORE(str->object.var));
+    addFromVarList(new_name_, new_name, 0, new_func, CALL_INTER_FUNCTIONSIG_CORE(obj->value->object.var));
+    addFromVarList(init_name_, init_name, 0, init_func, CALL_INTER_FUNCTIONSIG_CORE(obj->value->object.var));
 
     newObjectSettingPresetting(new_func, new_name, inter);
     newObjectSettingPresetting(init_func, init_name, inter);
@@ -268,7 +267,7 @@ void strFunctionPresetting(LinkValue *func, LinkValue *func_new, LinkValue *func
 }
 
 void makeBaseStr(Inter *inter){
-    Value *str = makeBaseChildClass(inter->data.vobject, inter);
+    LinkValue *str = makeBaseChildClass4(inter->data.vobject, inter);
     gc_addStatementLink(&str->gc_status);
     inter->data.str = str;
 }

+ 2 - 2
VirtulMathCore/ofunc/src/vobject.c

@@ -186,7 +186,7 @@ ResultType vobject_repo(OFFICAL_FUNCTIONSIG){
 }
 
 void registeredVObject(REGISTERED_FUNCTIONSIG){
-    LinkValue *object = makeLinkValue(inter->data.vobject, inter->base_father, inter);
+    LinkValue *object = inter->data.vobject;
     NameFunc tmp[] = {{inter->data.object_add, vobject_add, object_free_},
                       {inter->data.object_sub, vobject_sub, object_free_},
                       {inter->data.object_mul, vobject_mul, object_free_},
@@ -202,7 +202,7 @@ void registeredVObject(REGISTERED_FUNCTIONSIG){
 }
 
 void makeBaseVObject(Inter *inter){
-    Value *vobject = makeBaseChildClass(inter->data.object, inter);
+    LinkValue *vobject = makeBaseChildClass4(inter->data.object, inter);
     gc_addStatementLink(&vobject->gc_status);
     inter->data.vobject = vobject;
 }

+ 2 - 2
VirtulMathCore/src/__run.c

@@ -181,7 +181,7 @@ ResultType setFunctionArgument(Argument **arg, LinkValue *function_value, fline
         case class_free_:
             if (function_value->belong->value->type == class)
                 tmp = makeValueArgument(function_value->belong);
-            else if (function_value->value->object.inherit->value != NULL)
+            else if (function_value->value->object.inherit->value != NULL)  // TODO-szh 检查 function_value->value->object.inherit != NULL
                 tmp = makeValueArgument(function_value->belong->value->object.inherit->value);
             else
                 break;
@@ -357,7 +357,7 @@ char *getRepoStr(LinkValue *value, bool is_repot, fline line, char *file, INTER_
 }
 
 bool is_iterStop(LinkValue *value, Inter *inter) {
-    return value->value == inter->data.iterstop_exc || checkAttribution(value->value, inter->data.iterstop_exc);
+    return value->value == inter->data.iterstop_exc->value || checkAttribution(value->value, inter->data.iterstop_exc->value);
 }
 
 bool checkAut(enum ValueAuthority value, enum ValueAuthority base, fline line, char *file, char *name, bool pri_auto, INTER_FUNCTIONSIG_NOT_ST) {

+ 3 - 19
VirtulMathCore/src/ofunc.c

@@ -22,7 +22,7 @@ void registeredBaseFunction(struct LinkValue *father, Inter *inter){
 }
 
 void presetting(Inter *inter) {
-    LinkValue *func = makeLinkValue(inter->data.function, inter->base_father, inter);
+    LinkValue *func = inter->data.function;
     LinkValue *func_new = NULL;
     LinkValue *func_init = NULL;
 
@@ -32,7 +32,8 @@ void presetting(Inter *inter) {
 }
 
 void registeredFunctionName(Inter *inter, LinkValue *belong){
-    makeBaseObject(inter);
+    makeBaseObject(inter, belong);
+
     makeBaseVObject(inter);
     makeBaseNum(inter);
     makeBaseBool(inter);
@@ -44,25 +45,8 @@ void registeredFunctionName(Inter *inter, LinkValue *belong){
     makeBaseDictIter(inter);
     makeExcIter(inter);
 
-    {
-        Value *global_belong = makeObject(inter, copyVarList(inter->var_list, false, inter), NULL, NULL);
-        LinkValue *base_father = makeLinkValue(global_belong, belong, inter);
-        gc_addStatementLink(&base_father->gc_status);
-        inter->base_father = base_father;
-    }
-
     makeBaseStr(inter);
     presetting(inter);
     registeredObject(inter->base_father, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
-    {
-        Result result;
-        setResultCore(&result);
-        inter->data.none = makeNoneValue(0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(inter->var_list, &result, belong));
-        if (!RUN_TYPE(result.type))
-            printError(&result, inter, true);
-        else
-            gc_addStatementLink(&inter->data.none->gc_status);
-        freeResult(&result);
-    }
     registeredBaseFunction(inter->base_father, inter);
 }

+ 1 - 1
VirtulMathCore/src/run.c

@@ -327,5 +327,5 @@ Statement *checkLabel(Statement *base, char *label){
 }
 
 bool is_quitExc(LinkValue *value, Inter *inter) {
-    return value->value == inter->data.quit_exc || checkAttribution(value->value, inter->data.quit_exc);
+    return value->value == inter->data.quit_exc->value || checkAttribution(value->value, inter->data.quit_exc->value);
 }

+ 18 - 24
VirtulMathCore/src/value.c

@@ -7,7 +7,7 @@ Value *makeObject(Inter *inter, VarList *object, VarList *out_var, Inherit *inhe
     tmp->type = object_;
     tmp->gc_next = NULL;
     if (inter->data.object != NULL && inherit == NULL)
-        inherit = makeInherit(makeLinkValue(inter->data.object, NULL, inter));
+        inherit = makeInherit(inter->data.object);
     if (out_var == NULL && inherit != NULL)
         out_var = copyVarList(inherit->value->value->object.out_var, false, inter);
     tmp->object.var = makeObjectVarList(inherit, inter, object);
@@ -29,10 +29,10 @@ Value *makeObject(Inter *inter, VarList *object, VarList *out_var, Inherit *inhe
     return tmp;
 }
 
-Value *makeNoneValue(fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
+Value *makeNoneValue(fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {  // TODO-szh 删除该函数
     Value *tmp;
     setResultCore(result);
-    callBackCore(makeLinkValue(inter->data.object, inter->base_father, inter), NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.object, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -41,20 +41,20 @@ Value *makeNoneValue(fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
 }
 
 Value *useNoneValue(Inter *inter, Result *result) {
-    Value *tmp = inter->data.none;
+    LinkValue *tmp = inter->data.none;
     if (result != NULL) {
         setResultCore(result);
         result->type = operation_return;
-        result->value = makeLinkValue(tmp, inter->base_father, inter);
+        result->value = tmp;
         gc_addTmpLink(&result->value->gc_status);
     }
-    return tmp;
+    return tmp->value;
 }
 
 Value *makeBoolValue(bool bool_num, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
     Value *tmp = NULL;
     setResultCore(result);
-    callBackCore(makeLinkValue(inter->data.bool_, inter->base_father, inter), NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.bool_, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -65,7 +65,7 @@ Value *makeBoolValue(bool bool_num, fline line, char *file, INTER_FUNCTIONSIG_NO
 Value *makePassValue(fline line, char *file, INTER_FUNCTIONSIG_NOT_ST){  // TODO-szh 让切片支持该语法
     Value *tmp = NULL;
     setResultCore(result);
-    callBackCore(makeLinkValue(inter->data.pass_, inter->base_father, inter), NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.pass_, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -75,7 +75,7 @@ Value *makePassValue(fline line, char *file, INTER_FUNCTIONSIG_NOT_ST){  // TODO
 Value *makeNumberValue(vnum num, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
     Value *tmp = NULL;
     setResultCore(result);
-    callBackCore(makeLinkValue(inter->data.num, inter->base_father, inter), NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.num, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -86,7 +86,7 @@ Value *makeNumberValue(vnum num, fline line, char *file, INTER_FUNCTIONSIG_NOT_S
 Value *makeStringValue(char *str, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
     Value *tmp = NULL;
     setResultCore(result);
-    callBackCore(makeLinkValue(inter->data.str, inter->base_father, inter), NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.str, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -97,7 +97,7 @@ Value *makeStringValue(char *str, fline line, char *file, INTER_FUNCTIONSIG_NOT_
 
 Value *makeVMFunctionValue(Statement *st, Parameter *pt, INTER_FUNCTIONSIG_NOT_ST) {  // TODO-szh 设置无var_list的函数 (允许使用装饰器装饰,该功能未测试)
     Value *tmp = NULL;
-    callBackCore(makeLinkValue(inter->data.function, inter->base_father, inter), NULL, st->line, st->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.function, NULL, st->line, st->code_file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -114,7 +114,7 @@ Value *makeVMFunctionValue(Statement *st, Parameter *pt, INTER_FUNCTIONSIG_NOT_S
 
 Value *makeCFunctionValue(OfficialFunction of, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
     Value *tmp = NULL;
-    callBackCore(makeLinkValue(inter->data.function, inter->base_father, inter), NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.function, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -171,9 +171,9 @@ Value *makeListValue(Argument *arg, fline line, char *file, enum ListType type,
     Value *tmp = NULL;
     setResultCore(result);
     if (type == value_list)
-        callBackCore(makeLinkValue(inter->data.list, inter->base_father, inter), arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+        callBackCore(inter->data.list, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     else
-        callBackCore(makeLinkValue(inter->data.tuple, inter->base_father, inter), arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+        callBackCore(inter->data.tuple, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -182,9 +182,8 @@ Value *makeListValue(Argument *arg, fline line, char *file, enum ListType type,
 
 Value *makeDictValue(Argument *arg, bool new_hash, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST) {
     Value *tmp = NULL;
-    LinkValue *dict = makeLinkValue(inter->data.dict, inter->base_father, inter);
     setResultCore(result);
-    callBackCore(dict, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
+    callBackCore(inter->data.dict, arg, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result ,belong));
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
@@ -296,7 +295,7 @@ void setResultErrorSt(BaseErrorType type, char *error_message, bool new, Stateme
     setResultError(type, error_message, st->line, st->code_file, new, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
 }
 
-Value *findBaseError(BaseErrorType type, Inter *inter){
+LinkValue *findBaseError(BaseErrorType type, Inter *inter){
     switch (type) {
         case E_BaseException:
             return inter->data.base_exc;
@@ -388,11 +387,11 @@ void setResultError(BaseErrorType type, char *error_message, fline line, char *f
     if (!new && result->type != error_return)
         return;
     if (new) {
-        Value *exc = findBaseError(type, inter);
+        LinkValue *exc = findBaseError(type, inter);
         if (exc == NULL)
             exc = inter->data.base_exc;
         freeResult(result);
-        callException(makeLinkValue(exc, belong, inter), error_message, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        callException(exc, error_message, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     }
     else
         result->error = connectError(makeError(NULL, NULL, line, file), result->error);
@@ -527,11 +526,6 @@ Inherit *connectSafeInherit(Inherit *base, Inherit *back){
     return_: return base;
 }
 
-Inherit *getInheritFromValue(Value *value, Inter *inter){
-    LinkValue *num_father = makeLinkValue(value, inter->base_father, inter);
-    return getInheritFromValueCore(num_father);
-}
-
 Inherit *getInheritFromValueCore(LinkValue *num_father) {
     Inherit *object_father;
     Argument *father_arg = makeValueArgument(num_father);