Ver código fonte

fix: 修复赋值的错误

赋值语句没有设定result.value值(保持为null)
导致出现内存错误
原因: CHECK_RESULT前没有加`!`
SongZihuan 4 anos atrás
pai
commit
c0bf3224b0

+ 1 - 1
VirtulMathCore/ofunc/src/list.c

@@ -143,7 +143,7 @@ ResultType list_slice_assignment(O_FUNC){
         }
         freeResult(result);
         getIter(iter_obj, 0, LINEFILE, CNEXT_NT);
-        if (CHECK_RESULT(result)) {
+        if (CHECK_RESULT(result)) {  // 若没有出现Exception
             setResultError(E_TypeException, L"Iter Object Too Long", LINEFILE, true, CNEXT_NT);
             goto return_;
         } else if (!is_iterStop(result->value, inter))

+ 1 - 1
VirtulMathCore/ofunc/src/str.c

@@ -173,7 +173,7 @@ ResultType str_iter(O_FUNC){
     gc_addTmpLink(&to_list->gc_status);
     callBackCore(to_list, NULL, LINEFILE, 0, CNEXT_NT);
     gc_freeTmpLink(&to_list->gc_status);
-    if (CHECK_RESULT(result)) {
+    if (CHECK_RESULT(result)) {  // 若没有出现Exception
         LinkValue *str_list = NULL;
         str_list = result->value;
         result->value = NULL;

+ 1 - 0
VirtulMathCore/src/run.c

@@ -45,6 +45,7 @@ ResultType runStatement(FUNC) {
             break;
         case call_function:
             type = callBack(CNEXT);
+            printf("TAG A\n");
             break;
         case if_branch:
             type = ifBranch(CNEXT);

+ 1 - 1
VirtulMathCore/src/runcall.c

@@ -93,7 +93,7 @@ ResultType setFunction(FUNC) {
         freeResult(result);
     }
     assCore(st->u.set_function.name, func, false, true, CNEXT_NT);
-    if (CHECK_RESULT(result))
+    if (CHECK_RESULT(result))  // 若没有出现错误则设定none
         setResult(result, inter);
 
     error_:

+ 1 - 1
VirtulMathCore/src/runfile.c

@@ -264,7 +264,7 @@ ResultType importFile(FUNC) {
     else
         assCore(st->u.import_file.as, imp_value, false, is_new, CNEXT_NT);
 
-    if (CHECK_RESULT(result))
+    if (CHECK_RESULT(result))  // 若没有出现错误则设定none
         setResult(result, inter);
     gc_freeTmpLink(&imp_value->gc_status);
 

+ 3 - 4
VirtulMathCore/src/runoperation.c

@@ -276,8 +276,7 @@ ResultType assOperation(FUNC) {
         value = result->value;
 
         freeResult(result);
-        assCore(st->u.operation.left, value, false, false,
-                CNEXT_NT);
+        assCore(st->u.operation.left, value, false, false, CNEXT_NT);
     }
     return result->type;
 }
@@ -329,12 +328,12 @@ ResultType varAss(Statement *name, LinkValue *value, bool check_aut, bool settin
 
     if (tmp == NULL || !run || !setVarFunc(tmp, value, name->line, name->code_file, CNEXT_NT))
         addFromVarList(str_name, name_, int_times, value, CFUNC_CORE(var_list));
-    if (CHECK_RESULT(result))
+    if (!CHECK_RESULT(result))
         goto error_;
     if (setting) {
         freeResult(result);
         newObjectSetting(value, name->line, name->code_file, value, result, inter, var_list);
-        if (CHECK_RESULT(result))
+        if (!CHECK_RESULT(result))
             goto error_;
     }