Browse Source

feat: 增加__repo__函数

删除print_all等函数
print函数使用__repo__
SongZihuan 4 years ago
parent
commit
97bf380e33
12 changed files with 315 additions and 64 deletions
  1. 1 1
      include/value.h
  2. 4 2
      ofunc/src/bool.c
  3. 88 2
      ofunc/src/dict.c
  4. 8 24
      ofunc/src/io.c
  5. 58 0
      ofunc/src/list.c
  6. 19 4
      ofunc/src/object.c
  7. 25 2
      ofunc/src/str.c
  8. 56 0
      ofunc/src/vobject.c
  9. 21 0
      src/__run.c
  10. 1 0
      src/include/__run.h
  11. 3 3
      src/inter.c
  12. 31 26
      src/value.c

+ 1 - 1
include/value.h

@@ -185,7 +185,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, bool print_father);
+void printValue(Value *value, FILE *debug, bool print_father, bool print_in);
 void printLinkValue(LinkValue *value, char *first, char *last, FILE *debug);
 
 bool isType(Value *value, enum ValueType type);

+ 4 - 2
ofunc/src/bool.c

@@ -5,6 +5,7 @@ ResultType bool_init(OFFICAL_FUNCTIONSIG){
                            {.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     LinkValue *base;
+    bool new;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!CHECK_RESULT(result))
@@ -12,10 +13,11 @@ ResultType bool_init(OFFICAL_FUNCTIONSIG){
     freeResult(result);
 
     base = ap[0].value;
-    base->value->type = bool_;
-    base->value->data.bool_.bool_ = checkBool(ap[1].value, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    new = checkBool(ap[1].value, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!CHECK_RESULT(result))
         return result->type;
+    base->value->type = bool_;
+    base->value->data.bool_.bool_ = new;
     setResult(result, inter, belong);
     return result->type;
 }

+ 88 - 2
ofunc/src/dict.c

@@ -26,6 +26,29 @@ ResultType dict_down(OFFICAL_FUNCTIONSIG){
     return result->type;
 }
 
+ResultType dict_down_assignment(OFFICAL_FUNCTIONSIG){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.type=only_value, .must=1, .long_arg=false},
+                           {.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    char *name = NULL;
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+
+    if (ap[0].value->value->type != dict){
+        setResultError(E_TypeException, "Get Not Support Type", 0, "sys", true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        return error_return;
+    }
+
+    name = getNameFromValue(ap[2].value->value, inter);
+    addVar(name, ap[1].value, ap[2].value, inter, ap[0].value->value->data.dict.dict);
+    memFree(name);
+    return result->type;
+}
+
 ResultType dict_keys(OFFICAL_FUNCTIONSIG){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
@@ -77,11 +100,74 @@ ResultType dict_iter(OFFICAL_FUNCTIONSIG){
     return result->type;
 }
 
+ResultType dict_repo(OFFICAL_FUNCTIONSIG){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    char *repo = NULL;
+    Value *value = NULL;
+    LinkValue *again = NULL;
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+    value = ap[0].value->value;
+
+    if (value->type != dict){
+        setResultError(E_TypeException, "dict.__repo__ gets unsupported data", 0, "sys", true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        return error_return;
+    }
+    again = findAttributes("repo_again", false, ap[0].value, inter);
+    if (again != NULL){
+        bool again_ = checkBool(again, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        if (!CHECK_RESULT(result))
+            return result->type;
+        if (again_) {
+            setResultOperation(result, makeLinkValue(makeStringValue("{...}", inter), belong, inter));
+            return result->type;
+        }
+    }
+
+    addAttributes("repo_again", false, makeLinkValue(makeBoolValue(true, inter), belong, inter), ap[0].value, inter);
+    repo = memStrcpy("{");
+    for (int i = 0, count = 0; i < MAX_SIZE; i++) {
+        for (Var *var = value->data.dict.dict->hashtable[i]; var != NULL; var = var->next, count++) {
+            char *name_tmp;
+            char *value_tmp;
+            if (count > 0)
+                repo = memStrcat(repo, ", ", true, false);
+
+            freeResult(result);
+            name_tmp = getRepo(var->name_, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+            if (!CHECK_RESULT(result))
+                goto return_;
+            repo = memStrcat(repo, name_tmp, true, false);
+            repo = memStrcat(repo, ": ", true, false);
+
+            freeResult(result);
+            value_tmp = getRepo(var->value, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+            if (!CHECK_RESULT(result))
+                goto return_;
+            repo = memStrcat(repo, value_tmp, true, false);
+        }
+    }
+
+    repo = memStrcat(repo, "}", true, false);
+    setResultOperation(result, makeLinkValue(makeStringValue(repo, inter), belong, inter));
+
+    return_:
+    addAttributes("repo_again", false, makeLinkValue(makeBoolValue(false, inter), belong, inter), ap[0].value, inter);
+    memFree(repo);
+    return result->type;
+}
+
 void registeredDict(REGISTERED_FUNCTIONSIG){
     LinkValue *object = makeLinkValue(inter->data.dict, inter->base_father, inter);
-    NameFunc tmp[] = {{"__down__", dict_down, object_free_},
-                      {"keys", dict_keys, object_free_},
+    NameFunc tmp[] = {{"keys", dict_keys, object_free_},
+                      {"__down__", dict_down, object_free_},
                       {"__iter__", dict_iter, object_free_},
+                      {"__repo__", dict_repo, object_free_},
+                      {"__down_assignment__", dict_down_assignment, object_free_},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addStrVar("dict", false, true, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));

+ 8 - 24
ofunc/src/io.c

@@ -1,23 +1,10 @@
 #include "__ofunc.h"
-ResultType vm_printCore(OFFICAL_FUNCTIONSIG, int type);
 
 ResultType vm_print(OFFICAL_FUNCTIONSIG){
-    return vm_printCore(CALL_OFFICAL_FUNCTION(arg, var_list, result, belong), 2);
-}
-
-ResultType vm_printAll(OFFICAL_FUNCTIONSIG){
-    return vm_printCore(CALL_OFFICAL_FUNCTION(arg, var_list, result, belong), 1);
-}
-
-ResultType vm_printLink(OFFICAL_FUNCTIONSIG){
-    return vm_printCore(CALL_OFFICAL_FUNCTION(arg, var_list, result, belong), 0);
-}
-
-ResultType vm_printCore(OFFICAL_FUNCTIONSIG, int type){
-    setResultCore(result);
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=true},
                            {.type=name_value, .name="end", .must=0, .value=NULL},
                            {.must=-1}};
+    setResultCore(result);
     parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     if (!CHECK_RESULT(result))
         return result->type;
@@ -25,14 +12,13 @@ ResultType vm_printCore(OFFICAL_FUNCTIONSIG, int type){
 
     arg = ap[0].arg;
     for (int i=0; i < ap[0].c_count; arg = arg->next,i++){
+        freeResult(result);
+        char *tmp = getRepo(arg->data.value, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        if (!CHECK_RESULT(result))
+            return result->type;
         if (i != 0)
             fprintf(inter->data.inter_stdout, " ");
-        if (type == 0)
-            printLinkValue(arg->data.value, "", "", inter->data.inter_stdout);
-        else if (type == 1)
-            printValue(arg->data.value->value, inter->data.inter_stdout, true);
-        else
-            printValue(arg->data.value->value, inter->data.inter_stdout, false);
+        fprintf(inter->data.inter_stdout, "%s", tmp);
     }
 
     if (ap[1].value != NULL && ap[1].value->value->type == string)
@@ -40,7 +26,7 @@ ResultType vm_printCore(OFFICAL_FUNCTIONSIG, int type){
     else
         fprintf(inter->data.inter_stdout, "\n");
 
-    setResultBase(result, inter, belong);
+    setResult(result, inter, belong);
     return result->type;
 }
 
@@ -56,7 +42,7 @@ ResultType vm_input(OFFICAL_FUNCTIONSIG){
     freeResult(result);
 
     if (ap[0].value != NULL)
-        printValue(ap[0].value->value, inter->data.inter_stdout, false);
+        printValue(ap[0].value->value, inter->data.inter_stdout, false, true);
 
     while ((ch = fgetc(inter->data.inter_stdin)) != '\n' && ch != EOF)
         str = memStrCharcpy(str, 1, true, true, ch);
@@ -68,8 +54,6 @@ ResultType vm_input(OFFICAL_FUNCTIONSIG){
 
 void registeredIOFunction(REGISTERED_FUNCTIONSIG){
     NameFunc tmp[] = {{"print", vm_print, free_},
-                      {"print_link", vm_printLink, free_},
-                      {"print_all", vm_printAll, free_},
                       {"input", vm_input, free_},
                       {NULL, NULL}};
     iterNameFunc(tmp, belong, CALL_INTER_FUNCTIONSIG_CORE(var_list));

+ 58 - 0
ofunc/src/list.c

@@ -171,12 +171,70 @@ ResultType list_iter(OFFICAL_FUNCTIONSIG){
     return result->type;
 }
 
+ResultType list_repo(OFFICAL_FUNCTIONSIG){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    char *repo = NULL;
+    Value *value = NULL;
+    LinkValue *again = NULL;
+    enum ListType lt;
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+    value = ap[0].value->value;
+
+    if (value->type != list){
+        setResultError(E_TypeException, "list.__repo__ gets unsupported data", 0, "sys", true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        return error_return;
+    }
+    lt = value->data.list.type;
+    again = findAttributes("repo_again", false, ap[0].value, inter);
+    if (again != NULL){
+        bool again_ = checkBool(again, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        if (!CHECK_RESULT(result))
+            return result->type;
+        if (again_) {
+            setResultOperation(result, makeLinkValue(makeStringValue(lt == value_list ? "[...]" : "(...)", inter), belong, inter));
+            return result->type;
+        }
+    }
+
+    addAttributes("repo_again", false, makeLinkValue(makeBoolValue(true, inter), belong, inter), ap[0].value, inter);
+    if (lt == value_list)
+        repo = memStrcpy("[");
+    else
+        repo = memStrcpy("(");
+    for (int i=0;i < value->data.list.size;i++){
+        char *tmp;
+        freeResult(result);
+        if (i > 0)
+            repo = memStrcat(repo, ", ", true, false);
+        tmp = getRepo(value->data.list.list[i], 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        if (!CHECK_RESULT(result))
+            goto return_;
+        repo = memStrcat(repo, tmp, true, false);
+    }
+    if (lt == value_list)
+        repo = memStrcat(repo, "]", true, false);
+    else
+        repo = memStrcat(repo, ")", true, false);
+    setResultOperation(result, makeLinkValue(makeStringValue(repo, inter), belong, inter));
+
+    return_:
+    addAttributes("repo_again", false, makeLinkValue(makeBoolValue(false, inter), belong, inter), ap[0].value, inter);
+    memFree(repo);
+    return result->type;
+}
+
 void registeredList(REGISTERED_FUNCTIONSIG){
     {
         LinkValue *object = makeLinkValue(inter->data.tuple, inter->base_father, inter);
         NameFunc tmp[] = {{"__down__", list_down, object_free_},
                           {"__slice__", list_slice, object_free_},
                           {"__iter__", list_iter, object_free_},
+                          {"__repo__", list_repo, object_free_},
                           {NULL, NULL}};
         gc_addTmpLink(&object->gc_status);
         addStrVar("tuple", false, true, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));

+ 19 - 4
ofunc/src/object.c

@@ -5,7 +5,6 @@ ResultType object_new_(OFFICAL_FUNCTIONSIG){
     LinkValue *_init_ = NULL;
     setResultCore(result);
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
-                           {.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     int status = 1;
     arg = parserValueArgument(ap, arg, &status, NULL);
@@ -15,8 +14,8 @@ ResultType object_new_(OFFICAL_FUNCTIONSIG){
     }
 
     {
-        Inherit *object_father = getInheritFromValueCore(ap[1].value);
-        VarList *new_var = copyVarList(ap[1].value->value->object.out_var, false, inter);
+        Inherit *object_father = getInheritFromValueCore(ap[0].value);
+        VarList *new_var = copyVarList(ap[0].value->value->object.out_var, false, inter);
         Value *new_object = makeObject(inter, NULL, new_var, object_father);
         value = makeLinkValue(new_object, belong, inter);
         setResultOperation(result, value);
@@ -45,9 +44,25 @@ ResultType object_new_(OFFICAL_FUNCTIONSIG){
     return result->type;
 }
 
+ResultType object_repo_(OFFICAL_FUNCTIONSIG){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    char repo[200] = {};
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+    snprintf(repo, 200, "(object on %p)", ap[0].value->value);
+    setResultOperationBase(result, makeLinkValue(makeStringValue(repo, inter), belong, inter));
+    return result->type;
+}
+
 void registeredObject(REGISTERED_FUNCTIONSIG){
     LinkValue *object = makeLinkValue(inter->data.object, inter->base_father, inter);
-    NameFunc tmp[] = {{"__new__", object_new_, class_static_}, {NULL, NULL}};
+    NameFunc tmp[] = {{"__new__", object_new_, class_free_},
+                      {"__repo__", object_repo_, object_free_},
+                      {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addStrVar("object", false, true, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
     iterClassFunc(tmp, object, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));

+ 25 - 2
ofunc/src/str.c

@@ -1,11 +1,34 @@
 #include "__ofunc.h"
 
+ResultType str_init(OFFICAL_FUNCTIONSIG){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    LinkValue *base;
+    char *repo = NULL;
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+
+    base = ap[0].value;
+    repo = getRepo(ap[1].value, 0, "sys", CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    base->value->type = string;
+    base->value->data.str.str = memStrcpy(repo);
+    setResult(result, inter, belong);
+    return result->type;
+}
+
 void registeredStr(REGISTERED_FUNCTIONSIG){
     LinkValue *object = makeLinkValue(inter->data.str, inter->base_father, inter);
-//    NameFunc tmp[] = {{NULL, NULL}};
+    NameFunc tmp[] = {{"__init__", str_init, object_free_},
+                      {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addStrVar("str", false, true, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
-//    iterClassFunc(tmp, object, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
+    iterClassFunc(tmp, object, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));
     gc_freeTmpLink(&object->gc_status);
 }
 

+ 56 - 0
ofunc/src/vobject.c

@@ -134,6 +134,61 @@ ResultType vobject_bool(OFFICAL_FUNCTIONSIG){
     return result->type;
 }
 
+ResultType vobject_repo(OFFICAL_FUNCTIONSIG){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    char *repo = NULL;
+    Value *value = NULL;
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+    value = ap[0].value->value;
+
+    switch (value->type){
+        case number: {
+            char str[30] = {};
+            snprintf(str, 30, "%lld", value->data.num.num);
+            repo = memStrcpy(str);
+            break;
+        }
+        case string:
+            repo = memStrcpy(value->data.str.str);
+            break;
+        case function: {
+            char str[30] = {};
+            snprintf(str, 30, "(function on %p)", value);
+            repo = memStrcpy(str);
+            break;
+        }
+        case none:
+            repo = memStrcpy("(null)");
+            break;
+        case class: {
+            char str[30] = {};
+            snprintf(str, 30, "(class on %p)", value);
+            repo = memStrcpy(str);
+            break;
+        }
+        case bool_:
+            if (value->data.bool_.bool_)
+                repo = memStrcpy("true");
+            else
+                repo = memStrcpy("false");
+            break;
+        case pass_:
+            repo = memStrcpy("...");
+            break;
+        default:
+            setResultError(E_TypeException, "vobject.__repo__ gets unsupported data", 0, "sys", true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+            return error_return;
+    }
+    setResultOperationBase(result, makeLinkValue(makeStringValue(repo, inter), belong, inter));
+    memFree(repo);
+    return result->type;
+}
+
 void registeredVObject(REGISTERED_FUNCTIONSIG){
     LinkValue *object = makeLinkValue(inter->data.vobject, inter->base_father, inter);
     NameFunc tmp[] = {{"__add__", vobject_add, object_free_},
@@ -141,6 +196,7 @@ void registeredVObject(REGISTERED_FUNCTIONSIG){
                       {"__mul__", vobject_mul, object_free_},
                       {"__div__", vobject_div, object_free_},
                       {"__bool__", vobject_bool, object_free_},
+                      {"__repo__", vobject_repo, object_free_},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addStrVar("vobject", false, true, object, belong, CALL_INTER_FUNCTIONSIG_CORE(inter->var_list));

+ 21 - 0
src/__run.c

@@ -296,3 +296,24 @@ bool checkBool(LinkValue *value, fline line, char *file, INTER_FUNCTIONSIG_NOT_S
         setResultError(E_TypeException, "Object does not support __bool__ function", line, file, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
     return false;
 }
+
+char *getRepo(LinkValue *value, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST){
+    LinkValue *_repo_ = findAttributes("__repo__", false, value, inter);
+    setResultCore(result);
+    if (_repo_ != NULL){
+        gc_addTmpLink(&_repo_->gc_status);
+        callBackCore(_repo_, NULL, line, file, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+        gc_freeTmpLink(&_repo_->gc_status);
+
+        if (!CHECK_RESULT(result))
+            return NULL;
+        else if (result->value->value->type != string){
+            setResultError(E_TypeException, "__repo__ function should return str type data", line, file, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+            return NULL;
+        }
+        return result->value->value->data.str.str;
+    }
+    else
+        setResultError(E_TypeException, "list.__repo__ gets unsupported data", line, file, true, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result, belong));
+    return NULL;
+}

+ 1 - 0
src/include/__run.h

@@ -38,4 +38,5 @@ void newObjectSetting(LinkValue *name, LinkValue *belong, Inter *inter);
 ResultType elementDownOne(LinkValue *element, LinkValue *index, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST);
 ResultType getIter(LinkValue *value, int status, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST);
 bool checkBool(LinkValue *value, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST);
+char *getRepo(LinkValue *value, fline line, char *file, INTER_FUNCTIONSIG_NOT_ST);
 #endif //VIRTUALMATH___RUN_H

+ 3 - 3
src/inter.c

@@ -276,7 +276,7 @@ void printValueGC(char *tag, Inter *inter, long *tmp_link, long *st_link) {
             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, true);
+            printValue(base, stdout, true, true);
             printf("\n-------------------------------------------\n");
         }
         base = base->gc_next;
@@ -302,9 +302,9 @@ void printVarGC(char *tag, Inter *inter){
 
         printf("str_name = %s\n", base->name);
         printf("name = ");
-        printValue(base->name_->value,stdout, false);
+        printValue(base->name_->value, stdout, false, true);
         printf("\nvalue = ");
-        printValue(base->value->value,stdout, false);
+        printValue(base->value->value, stdout, false, true);
         printf("\n-------------------------------------------\n");
         base = base->gc_next;
     }

+ 31 - 26
src/value.c

@@ -391,7 +391,7 @@ void freeResultSafe(Result *ru){
     ru->error = NULL;
 }
 
-void printValue(Value *value, FILE *debug, bool print_father) {
+void printValue(Value *value, FILE *debug, bool print_father, bool print_in) {
     switch (value->type){
         case number:
             fprintf(debug, "%lld", value->data.num.num);
@@ -406,32 +406,37 @@ void printValue(Value *value, FILE *debug, bool print_father) {
                 fprintf(debug, "(function on %p)", value);
             break;
         case list:
-            fprintf(debug, "[");
-            for (int i=0;i < value->data.list.size;i++){
-                if (i > 0)
-                    fprintf(debug, ", ", NULL);
-                printValue(value->data.list.list[i]->value, debug, false);
-            }
-            fprintf(debug, " ]", NULL);
-            break;
-        case dict: {
-            Var *tmp = NULL;
-            bool print_comma = false;
-            fprintf(debug, "{");
-            for (int i = 0; i < MAX_SIZE; i++) {
-                for (tmp = value->data.dict.dict->hashtable[i]; tmp != NULL; tmp = tmp->next) {
-                    if (print_comma)
+            if (print_in){
+                fprintf(debug, "[");
+                for (int i = 0; i < value->data.list.size; i++) {
+                    if (i > 0)
                         fprintf(debug, ", ", NULL);
-                    else
-                        print_comma = true;
-                    printValue(tmp->name_->value, debug, false);
-                    fprintf(debug, " ['%s'] : ", tmp->name);
-                    printValue(tmp->value->value, debug, false);
+                    printValue(value->data.list.list[i]->value, debug, false, false);
                 }
-            }
-            fprintf(debug, " }", NULL);
+                fprintf(debug, " ]", NULL);
+            } else
+                fprintf(debug, "[list]", NULL);
+            break;
+        case dict:
+            if (print_in){
+                Var *tmp = NULL;
+                bool print_comma = false;
+                fprintf(debug, "{");
+                for (int i = 0; i < MAX_SIZE; i++) {
+                    for (tmp = value->data.dict.dict->hashtable[i]; tmp != NULL; tmp = tmp->next) {
+                        if (print_comma)
+                            fprintf(debug, ", ", NULL);
+                        else
+                            print_comma = true;
+                        printValue(tmp->name_->value, debug, false, false);
+                        fprintf(debug, " ['%s'] : ", tmp->name);
+                        printValue(tmp->value->value, debug, false, false);
+                    }
+                }
+                fprintf(debug, " }", NULL);
+            } else
+                fprintf(debug, "[dict]", NULL);
             break;
-        }
         case none:
             fprintf(debug, "(null)", NULL);
             break;
@@ -465,7 +470,7 @@ void printValue(Value *value, FILE *debug, bool print_father) {
         printf("<%p>", value);
         for (Inherit *fv = value->object.inherit; fv != NULL; fv = fv->next) {
             printf(" -> ");
-            printValue(fv->value->value, debug, false);
+            printValue(fv->value->value, debug, false, false);
         }
         fprintf(debug, ")");
     }
@@ -481,7 +486,7 @@ void printLinkValue(LinkValue *value, char *first, char *last, FILE *debug){
         fprintf(debug, " . ", NULL);
     }
     if (value->value != NULL)
-        printValue(value->value, debug, true);
+        printValue(value->value, debug, true, true);
     fprintf(debug, "%s", last);
 }