|
@@ -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));
|