浏览代码

feat: 允许使用super函数获得object的父类

SongZihuan 4 年之前
父节点
当前提交
f933ca28b0
共有 20 个文件被更改,包括 123 次插入53 次删除
  1. 2 0
      include/ofunc.h
  2. 1 1
      include/parameter.h
  3. 1 1
      include/value.h
  4. 12 0
      ofunc/include/__base.h
  5. 2 0
      ofunc/include/__ofunc.h
  6. 1 2
      ofunc/include/io.h
  7. 0 1
      ofunc/include/object.h
  8. 7 0
      ofunc/include/sys.h
  9. 1 1
      ofunc/src/io.c
  10. 7 3
      ofunc/src/object.c
  11. 39 0
      ofunc/src/sys.c
  12. 1 0
      parser/grammar.c
  13. 3 4
      src/__run.c
  14. 1 1
      src/inter.c
  15. 1 0
      src/ofunc.c
  16. 16 19
      src/parameter.c
  17. 4 4
      src/runbranch.c
  18. 1 5
      src/runcall.c
  19. 6 6
      src/runoperation.c
  20. 17 5
      src/value.c

+ 2 - 0
include/ofunc.h

@@ -3,9 +3,11 @@
 #include "__macro.h"
 #include "io.h"
 #include "object.h"
+#include "sys.h"
 
 struct Argument;
 struct VarList;
+struct FatherValue;
 typedef enum ResultType (*OfficialFunction)(OfficialFunctionSig);
 typedef void (*Registered)(RegisteredFunctionSig);
 

+ 1 - 1
include/parameter.h

@@ -75,6 +75,6 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
 ResultType argumentToParameter(Argument **call_ad, Parameter **function_ad, VarList *function_var, INTER_FUNCTIONSIG_NOT_ST);
 
 FatherValue *setFatherCore(FatherValue *father_tmp);
-FatherValue *setFather(Argument *call, INTER_FUNCTIONSIG_NOT_ST);
+FatherValue *setFather(Argument *call);
 bool checkFormal(Parameter *pt);
 #endif //VIRTUALMATH_PARAMETER_H

+ 1 - 1
include/value.h

@@ -153,7 +153,7 @@ void freeError(Result *base);
 Error *connectError(Error *new, Error *base);
 void printError(Result *result, Inter *inter, bool free);
 
-void printValue(Value *value, FILE *debug);
+void printValue(Value *value, FILE *debug, bool print_father);
 void printLinkValue(LinkValue *value, char *first, char *last, FILE *debug);
 
 bool isType(Value *value, enum ValueType type);

+ 12 - 0
ofunc/include/__base.h

@@ -0,0 +1,12 @@
+#ifndef VIRTUALMATH___BASE_H
+#define VIRTUALMATH___BASE_H
+#include "__macro.h"
+
+struct Inter;
+struct VarList;
+struct FatherValue;
+struct LinkValue;
+struct Result;
+typedef enum ResultType ResultType;
+
+#endif //VIRTUALMATH___BASE_H

+ 2 - 0
ofunc/include/__ofunc.h

@@ -1,8 +1,10 @@
 #ifndef VIRTUALMATH___OFUNC_H
 #define VIRTUALMATH___OFUNC_H
 #include "__virtualmath.h"
+#include "__base.h"
 #include "__run.h"
 
+
 void registeredFunctionCore(OfficialFunction of, char *name, struct LinkValue *father, INTER_FUNCTIONSIG_CORE);
 void iterNameFunc(NameFunc list[],struct LinkValue *father, INTER_FUNCTIONSIG_CORE);
 

+ 1 - 2
ofunc/include/io.h

@@ -1,7 +1,6 @@
 #ifndef VIRTUALMATH_IO_H
 #define VIRTUALMATH_IO_H
-#include "__macro.h"
+#include "__base.h"
 
-typedef enum ResultType ResultType;
 void registeredIOFunction(RegisteredFunctionSig);
 #endif //VIRTUALMATH_IO_H

+ 0 - 1
ofunc/include/object.h

@@ -2,7 +2,6 @@
 #define VIRTUALMATH_OBJECT_H
 #include "__macro.h"
 
-typedef enum ResultType ResultType;
 void registeredObject(RegisteredFunctionSig);
 void makeBaseObject(Inter *inter);
 #endif //VIRTUALMATH_OBJECT_H

+ 7 - 0
ofunc/include/sys.h

@@ -0,0 +1,7 @@
+#ifndef VIRTUALMATH_SYS_H
+#define VIRTUALMATH_SYS_H
+#include "__macro.h"
+
+
+void registeredSysFunction(RegisteredFunctionSig);
+#endif //VIRTUALMATH_SYS_H

+ 1 - 1
ofunc/src/io.c

@@ -7,7 +7,7 @@ ResultType vm_print(OfficialFunctionSig){
         return error_return;
     }
     for (arg = arg->next->next; arg != NULL; arg = arg->next)
-        printLinkValue(arg->data.value, "", "", stdout);
+        printValue(arg->data.value->value, stdout, true);
     printf("\n");
     return result->type;
 }

+ 7 - 3
ofunc/src/object.c

@@ -6,9 +6,13 @@ ResultType object_new_(OfficialFunctionSig){
     setResultCore(result);
 
     {
-        FatherValue *father_value = setFatherCore(makeFatherValue(arg->data.value));
-        VarList *new_var = copyVarList(arg->data.value->value->object.out_var, false, inter);
-        Value *new_object = makeObject(inter, NULL, new_var, father_value);
+        VarList *new_var = NULL;
+        Value *new_object = NULL;
+        Argument *father_arg = makeValueArgument(arg->next->data.value);
+        FatherValue *object_father = setFather(father_arg);
+        freeArgument(father_arg, true);
+        new_var = copyVarList(arg->next->data.value->value->object.out_var, false, inter);
+        new_object = makeObject(inter, NULL, new_var, object_father);
         value = makeLinkValue(new_object, father, inter);
         setResultOperation(result, value);
     }

+ 39 - 0
ofunc/src/sys.c

@@ -0,0 +1,39 @@
+#include "__ofunc.h"
+
+ResultType vm_super(OfficialFunctionSig){
+    Value *arg_father = NULL;
+    Value *arg_child = NULL;
+    LinkValue *next_father = NULL;
+    setResultCore(result);
+
+    arg = arg->next->next;
+    if (arg != NULL && arg->next != NULL){
+        arg_father = arg->data.value->value;
+        arg_child = arg->next->data.value->value;
+    } else{
+        setResultError(result, inter, "ArgumentException", "Don't get Enough Argument", 0, "sys", father, true);
+        return error_return;
+    }
+    for (FatherValue *self_father = arg_child->object.father; 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);
+            break;
+        }
+    }
+
+    if (next_father != NULL){
+        result->value = next_father;
+        result->type = operation_return;
+        gc_addTmpLink(&result->value->gc_status);
+    }
+    else
+        setResultError(result, inter, "SuperException", "Don't get next father", 0, "sys", father, true);
+
+    return result->type;
+}
+
+void registeredSysFunction(RegisteredFunctionSig){
+    NameFunc tmp[] = {{"super", vm_super}, {NULL, NULL}};
+    iterNameFunc(tmp, father, CALL_INTER_FUNCTIONSIG_CORE(var_list));
+}

+ 1 - 0
parser/grammar.c

@@ -960,6 +960,7 @@ void parserCode(PASERSSIGNATURE) {
         goto error_;
 
     if (!checkToken(pm, MATHER_RC)) {
+        printf("tk = %d\n", readBackToken(pm));
         syntaxError(pm, syntax_error, line, 1, "Don't get the }");  // 使用{的行号
         goto error_;
     }

+ 3 - 4
src/__run.c

@@ -126,13 +126,12 @@ Statement *getRunInfoStatement(Statement *funtion_st){  // TODO-szh 去除该函
 ResultType setFunctionArgument(Argument **arg, LinkValue *function_value, long line, char *file, INTER_FUNCTIONSIG_NOT_ST){
     Argument *tmp = NULL;
     setResultCore(result);
-    if (function_value->father != NULL)
-        tmp = makeValueArgument(function_value->father);
-    else{
+    if (function_value->father == NULL){
         setResultError(result, inter, "ArgumentException", "Don't get self", line, file, father, true);
         return error_return;
     }
-    tmp->next = makeValueArgument(function_value);
+    tmp = makeValueArgument(function_value);
+    tmp->next = makeValueArgument(function_value->father);
     tmp->next->next = *arg;
     *arg = tmp;
     setResultBase(result, inter, father);

+ 1 - 1
src/inter.c

@@ -158,7 +158,7 @@ void printValueGC(char *tag, Inter *inter){
         printf("inter->link_base.statement_link = %ld :: %p\n", base->gc_status.statement_link, base);
         printf("inter->link_base.link           = %ld :: %p\n", base->gc_status.link, base);
         printf("value = ");
-        printValue(base, stdout);
+        printValue(base, stdout, true);
         printf("\n-------------------------------------------\n");
         base = base->gc_next;
     }

+ 1 - 0
src/ofunc.c

@@ -2,6 +2,7 @@
 
 static Registered base_func_list[] = {registeredIOFunction,
                                       registeredObject,
+                                      registeredSysFunction,
                                       NULL};
 
 void registeredBaseFunction(struct LinkValue *father, Inter *inter){

+ 16 - 19
src/parameter.c

@@ -216,7 +216,7 @@ ResultType defaultParameter(Parameter **function_ad, NUMBER_TYPE *num, INTER_FUN
 
         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, father));
         if (!run_continue(result))
             goto return_;
     }
@@ -245,7 +245,7 @@ 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, father));
         if (!run_continue(result))
             goto return_;
     }
@@ -279,7 +279,7 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
         get = true;
 
         if (function->type == kwargs_par){
-            value = makeLinkValue(makeDictValue(NULL, false, father, NULL, inter, var_list), father, inter);
+            value = makeLinkValue(makeDictValue(NULL, false, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, NULL, father)), father, inter);
             value->value->data.dict.dict = var_list->hashtable;
             value->value->data.dict.size = max - *num;
             *status = true;
@@ -321,7 +321,7 @@ ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, NUMB
 
         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, father));
 
         if (!run_continue(result)) {
             *function_ad = function;
@@ -356,7 +356,7 @@ 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, father));
         if (!run_continue(result))
             goto return_;
         freeResult(result);
@@ -423,7 +423,7 @@ Argument * getArgument(Parameter *call, bool is_dict, INTER_FUNCTIONSIG_NOT_ST)
     Argument *new_arg = NULL;
     freeResult(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, father));
     return new_arg;
 }
 
@@ -448,7 +448,7 @@ ResultType setParameter(long int line, char *file, Parameter *call_base, Paramet
     Argument *father_tmp = makeValueArgument(function_father->father);
     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, father));
     self_tmp->next = father_tmp;
     father_tmp->next = call;
     if (!run_continue(result)) {
@@ -457,7 +457,7 @@ ResultType setParameter(long int line, char *file, Parameter *call_base, Paramet
     }
 
     freeResult(result);
-    setParameterCore(line, file, self_tmp, function_base, function_var, CALL_INTER_FUNCTIONSIG_NOT_ST (var_list, result, function_father));
+    setParameterCore(line, file, self_tmp, function_base, function_var, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, function_father));
     freeArgument(self_tmp, false);
     return result->type;
 }
@@ -499,13 +499,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, father));
                 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, father));
                 returnResult(result);
                 break;
             }
@@ -515,7 +515,7 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
                 bool dict_status = false;
                 VarList *tmp = pushVarList(var_list, inter);
 
-                argumentToVar(&call, &set_num, CALL_INTER_FUNCTIONSIG_NOT_ST (tmp, result, father));
+                argumentToVar(&call, &set_num, CALL_INTER_FUNCTIONSIG_NOT_ST(tmp, result, father));
                 returnResult(result);
                 if (!run_continue(result)) {
                     popVarList(tmp);
@@ -523,7 +523,7 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
                 }
 
                 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, father));
                 if (!run_continue(result)) {
                     popVarList(tmp);
                     goto return_;
@@ -543,14 +543,14 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
                 else
                     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, father));
                 returnResult(result);
                 function = function->next;
                 break;
             }
             case space_kwargs:{
-                LinkValue *tmp = makeLinkValue(makeDictValue(NULL, true, father, result, inter, var_list), father, inter);
-                assCore(function->data.value, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST (function_var, result, father));
+                LinkValue *tmp = makeLinkValue(makeDictValue(NULL, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father)), father, inter);
+                assCore(function->data.value, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(function_var, result, father));
                 returnResult(result);
                 function = function->next;
                 break;
@@ -571,16 +571,13 @@ ResultType setParameterCore(long int line, char *file, Argument *call, Parameter
     return result->type;
 }
 
-FatherValue *setFather(Argument *call, INTER_FUNCTIONSIG_NOT_ST) {
-    setResultCore(result);
-
+FatherValue *setFather(Argument *call) {
     FatherValue *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));
         }
-
     return setFatherCore(father_tmp);
 }
 

+ 4 - 4
src/runbranch.c

@@ -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, father));
                 if (!run_continue(result)){
                     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, father));
             if (!run_continue(result)){
                 set_result = false;
                 goto not_else;
@@ -414,7 +414,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, father));
             if (!run_continue(result)) {
                 set_result = false;
                 popVarList(new);
@@ -563,7 +563,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, father));
         if (!run_continue(result)){
             set_result = false;
             goto not_else;

+ 1 - 5
src/runcall.c

@@ -11,12 +11,8 @@ ResultType setClass(INTER_FUNCTIONSIG) {
     if (!run_continue(result))
         goto error_;
 
-    freeResult(result);
-    class_father = setFather(call, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
+    class_father = setFather(call);
     freeArgument(call, true);
-    if (!run_continue(result))
-        goto error_;
-
     tmp = makeLinkValue(makeClassValue(copyVarList(var_list, false, inter), inter, class_father), father, inter);
     gc_addTmpLink(&tmp->gc_status);
 

+ 6 - 6
src/runoperation.c

@@ -244,7 +244,7 @@ ResultType assOperation(INTER_FUNCTIONSIG) {
         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, father));
     }
     return result->type;
 }
@@ -259,7 +259,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, father));
         if (!run_continue(result)) {
             freeArgument(call, false);
             freeParameter(pt, true);
@@ -278,7 +278,7 @@ 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, father));
     else{
         char *str_name = NULL;
         int int_times = 0;
@@ -395,7 +395,7 @@ 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, father));
     at_tmp = at;
     if (!run_continue(result)){
         freeArgument(at_tmp, true);
@@ -414,7 +414,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, father));
     at_tmp = at;
     if (!run_continue(result)){
         freeArgument(at_tmp, false);
@@ -422,7 +422,7 @@ ResultType getDict(INTER_FUNCTIONSIG) {
     }
 
     freeResult(result);
-    Value *tmp_value = makeDictValue(&at, true, father, result, inter, var_list);
+    Value *tmp_value = makeDictValue(&at, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, father));
     if (!run_continue(result)) {
         freeArgument(at_tmp, false);
         return result->type;

+ 17 - 5
src/value.c

@@ -70,6 +70,7 @@ Value *makeStringValue(char *str, Inter *inter) {
     return tmp;
 }
 
+
 Value *makeVMFunctionValue(Statement *st, Parameter *pt, VarList *var_list, Inter *inter) {
     Value *tmp;
     tmp = makeObject(inter, NULL, var_list, NULL);
@@ -285,7 +286,7 @@ void freeResultSafe(Result *ru){
     ru->error = NULL;
 }
 
-void printValue(Value *value, FILE *debug){
+void printValue(Value *value, FILE *debug, bool print_father) {
     switch (value->type){
         case number:
             fprintf(debug, "%"NUMBER_FORMAT"", value->data.num.num);
@@ -348,8 +349,11 @@ void printValue(Value *value, FILE *debug){
     }
     fprintf(debug, "(");
     printf("<%p>", value);
-//    for (FatherValue *fv = value->object.father; fv != NULL; fv = fv->next)
-//        printLinkValue(fv->value, " -> ", "", debug);
+    if (print_father)
+        for (FatherValue *fv = value->object.father; fv != NULL; fv = fv->next) {
+            printf(" -> ");
+            printValue(fv->value->value, debug, false);
+        }
     fprintf(debug, ")");
 
 }
@@ -363,7 +367,7 @@ void printLinkValue(LinkValue *value, char *first, char *last, FILE *debug){
         fprintf(debug, " . ", NULL);
     }
     if (value->value != NULL)
-        printValue(value->value, debug);
+        printValue(value->value, debug, true);
     fprintf(debug, "%s", last);
 }
 
@@ -417,7 +421,7 @@ FatherValue *makeFatherValue(LinkValue *value){
     return tmp;
 }
 
-FatherValue *copyFatherValue(FatherValue *value){
+FatherValue *copyFatherValueCore(FatherValue *value){
     FatherValue *tmp;
     if (value == NULL)
         return NULL;
@@ -425,6 +429,14 @@ FatherValue *copyFatherValue(FatherValue *value){
     return tmp;
 }
 
+FatherValue *copyFatherValue(FatherValue *value){
+    FatherValue *base = NULL;
+    FatherValue **tmp = &base;
+    for (PASS; value != NULL; value = value->next, tmp = &(*tmp)->next)
+        *tmp = copyFatherValueCore(value);
+    return base;
+}
+
 FatherValue *freeFatherValue(FatherValue *value){
     freeBase(value, error_);
     FatherValue *next = value->next;