소스 검색

style: 格式化部分代码

SongZihuan 4 년 전
부모
커밋
178bcda32e
6개의 변경된 파일173개의 추가작업 그리고 110개의 파일을 삭제
  1. 11 8
      vmcore/include/mem.h
  2. 48 34
      vmcore/ofunc/src/object.c
  3. 109 60
      vmcore/ofunc/src/vobject.c
  4. 1 1
      vmcore/parser/include/__grammar.h
  5. 4 6
      vmcore/src/runbranch.c
  6. 0 1
      vmcore/src/runfile.c

+ 11 - 8
vmcore/include/mem.h

@@ -1,7 +1,7 @@
 #ifndef VIRTUALMATH_MEM_H
 #define VIRTUALMATH_MEM_H
-#include <string.h>
 #include <__macro.h>
+#include <string.h>
 
 extern jmp_buf memVirtualMath_Env;
 extern bool memVirtualMathUseJmp;
@@ -11,24 +11,27 @@ void *memCalloc(size_t num, size_t size);
 void *memRealloc(void *old, size_t size);
 char *memStrcpy(const char *str);
 wchar_t *memWidecpy(const wchar_t *str);
-wchar_t *memWideCharcpy(wchar_t *str, size_t nsize, bool free_old, bool write, ...);
+wchar_t *memWideCharcpy(wchar_t *str, size_t nsize, bool free_old, bool write,
+                        ...);
 wchar_t *memWideExpansion(wchar_t *str, size_t nsize, bool free_old);
 char *memStrcatIter(char *base, bool free_base, ...);
 char *memStrcat(char *first, char *second, bool free_first, bool free_last);
-wchar_t *memWidecat(wchar_t *first, wchar_t *second, bool free_first, bool free_last);
+wchar_t *memWidecat(wchar_t *first, wchar_t *second, bool free_first,
+                    bool free_last);
 wchar_t *memWidecpySelf(wchar_t *str, long times);
 wchar_t *memWiderev(wchar_t *str);
 char *memWcsToStr(wchar_t *wcs, bool free_old);
 wchar_t *memStrToWcs(char *str, bool free_old);
 
-#define memFree(p) ((p)=((p) != NULL ? (free((p)), NULL) : NULL))
+#define memFree(p) ((p) = ((p) != NULL ? (free((p)), NULL) : NULL))
 #define eqString(str1, str2) (!strcmp((str1), (str2)))
 #define eqWide(wid1, wid2) (!wcscmp((wchar_t *)(wid1), (wchar_t *)(wid2)))
 #define memString(size) (char *)memCalloc((size) + 1, sizeof(char))
 #define memWide(size) (wchar_t *)memCalloc((size) + 1, sizeof(wchar_t))
-#define memStrlen(p) (((p) == NULL) ? 0 :strlen((p)))
-#define memWidelen(p) (((p) == NULL) ? 0 :wcslen((p)))
+#define memStrlen(p) (((p) == NULL) ? 0 : strlen((p)))
+#define memWidelen(p) (((p) == NULL) ? 0 : wcslen((p)))
 
-#define MACRO_CALLOC(var, n, size) (((var = (typeof(var))calloc(n, size)) == NULL) ? (memError()) : (var))
+#define MACRO_CALLOC(var, n, size)                                             \
+  ((((var) = (typeof(var))calloc(n, size)) == NULL) ? (memError()) : (var))
 
-#endif //VIRTUALMATH_MEM_H
+#endif // VIRTUALMATH_MEM_H

+ 48 - 34
vmcore/ofunc/src/object.c

@@ -1,13 +1,13 @@
 #include "__ofunc.h"
 
-static ResultType object_new(O_FUNC){
+static ResultType object_new(O_FUNC) {
     LinkValue *value = NULL;
     setResultCore(result);
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     int status = 1;
     arg = parserValueArgument(ap, arg, &status, NULL);
-    if (status != 1){
+    if (status != 1) {
         setResultError(E_ArgumentException, FEW_ARG, LINEFILE, true, CNEXT_NT);
         return R_error;
     }
@@ -38,27 +38,40 @@ static ResultType object_new(O_FUNC){
 }
 
 OBJ_OPT(ADD, Add, add)
+
 OBJ_OPT(SUB, Sub, sub)
+
 OBJ_OPT(MUL, Mul, mul)
+
 OBJ_OPT(DIV, Div, div)
+
 OBJ_OPT(INTDIV, Int Div, intdiv)
+
 OBJ_OPT(MOD, Mod, mod)
+
 OBJ_OPT(POW, Pow, pow)
 
 OBJ_OPT(MOREEQ, More Eq, moreeq)
+
 OBJ_OPT(LESSEQ, Less Eq, lesseq)
+
 OBJ_OPT(MORE, More, more)
+
 OBJ_OPT(LESS, Less, less)
 
 OBJ_OPT(BAND, Bit And, band)
+
 OBJ_OPT(BOR, Bit Or, bor)
+
 OBJ_OPT(BXOR, Bit Xor, bxor)
+
 OBJ_OPT(BL, Bit Left, bl)
+
 OBJ_OPT(BR, Bit Right, br)
 
 #undef OBJ_OPT
 
-static ResultType object_eq (O_FUNC) {
+static ResultType object_eq(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=name_value, .name=L"left", .must=1, .long_arg=false},
                            {.type=name_value, .name=L"right", .must=1, .long_arg=false},
@@ -72,7 +85,7 @@ static ResultType object_eq (O_FUNC) {
     return result->type;
 }
 
-static ResultType object_noteq (O_FUNC) {
+static ResultType object_noteq(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=name_value, .name=L"left", .must=1, .long_arg=false},
                            {.type=name_value, .name=L"right", .must=1, .long_arg=false},
@@ -86,7 +99,7 @@ static ResultType object_noteq (O_FUNC) {
     return result->type;
 }
 
-static ResultType objectRepoStrCore(O_FUNC){
+static ResultType objectRepoStrCore(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     wchar_t *repo;
@@ -99,12 +112,13 @@ static ResultType objectRepoStrCore(O_FUNC){
         return result->type;
     freeResult(result);
 
-    name_value = findAttributes(inter->data.mag_func[M_NAME], false, LINEFILE, true, CFUNC_NT(var_list, result, ap[0].value));
+    name_value = findAttributes(inter->data.mag_func[M_NAME], false, LINEFILE, true,
+                                CFUNC_NT(var_list, result, ap[0].value));
     if (!CHECK_RESULT(result))
         return result->type;
     freeResult(result);
 
-    if (name_value != NULL){
+    if (name_value != NULL) {
         if (name_value->value->type == V_str)
             name = name_value->value->data.str.str;
         else {
@@ -132,32 +146,32 @@ static ResultType objectRepoStrCore(O_FUNC){
     return result->type;
 }
 
-void registeredObject(R_FUNC){
+void registeredObject(R_FUNC) {
     LinkValue *object = inter->data.base_obj[B_OBJECT];
-    NameFunc tmp[] = {{inter->data.mag_func[M_ADD], object_add, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_SUB], object_sub, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MUL], object_mul, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DIV], object_div, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INTDIV], object_intdiv, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MOD], object_mod, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_POW], object_pow, fp_obj, .var=nfv_notpush},
-
-                      {inter->data.mag_func[M_EQ], object_eq, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NOTEQ], object_noteq, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MOREEQ], object_moreeq, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_LESSEQ], object_lesseq, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MORE], object_more, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_LESS], object_less, fp_obj, .var=nfv_notpush},
-
-                      {inter->data.mag_func[M_BAND], object_band, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BOR], object_bor, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BXOR], object_bxor, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BL], object_bl, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BR], object_br, fp_obj, .var=nfv_notpush},
-
-                      {inter->data.mag_func[M_NEW],  object_new,  fp_class, .var=nfv_notpush},
-                      {inter->data.mag_func[M_REPO], objectRepoStrCore, fp_all, .var=nfv_notpush},
-                      {inter->data.mag_func[M_STR],  objectRepoStrCore,  fp_all, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_ADD],    object_add,        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_SUB],    object_sub,        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MUL],    object_mul,        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DIV],    object_div,        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INTDIV], object_intdiv,     fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MOD],    object_mod,        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_POW],    object_pow,        fp_obj, .var=nfv_notpush},
+
+                      {inter->data.mag_func[M_EQ],     object_eq,         fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NOTEQ],  object_noteq,      fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MOREEQ], object_moreeq,     fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_LESSEQ], object_lesseq,     fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MORE],   object_more,       fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_LESS],   object_less,       fp_obj, .var=nfv_notpush},
+
+                      {inter->data.mag_func[M_BAND],   object_band,       fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BOR],    object_bor,        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BXOR],   object_bxor,       fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BL],     object_bl,         fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BR],     object_br,         fp_obj, .var=nfv_notpush},
+
+                      {inter->data.mag_func[M_NEW],    object_new,        fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_REPO],   objectRepoStrCore, fp_all, .var=nfv_notpush},
+                      {inter->data.mag_func[M_STR],    objectRepoStrCore, fp_all, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"object", object, belong, inter);
@@ -165,7 +179,7 @@ void registeredObject(R_FUNC){
     gc_freeTmpLink(&object->gc_status);
 }
 
-void makeBaseObject(Inter *inter, LinkValue *belong){
+void makeBaseObject(Inter *inter, LinkValue *belong) {
     LinkValue *g_belong;
     Value *object = makeClassValue(inter->var_list, inter, NULL);
 
@@ -180,7 +194,7 @@ void makeBaseObject(Inter *inter, LinkValue *belong){
     inter->data.base_obj[B_OBJECT] = makeLinkValue(object, g_belong, auto_aut, inter);
     gc_freeTmpLink(&object->gc_status);
     gc_addStatementLink(&inter->data.base_obj[B_OBJECT]->gc_status);
-    for (Inherit *ih=g_belong->value->object.inherit; ih != NULL; ih = ih->next) {
+    for (Inherit *ih = g_belong->value->object.inherit; ih != NULL; ih = ih->next) {
         if (ih->value->value == object)
             ih->value->belong = g_belong;
     }

+ 109 - 60
vmcore/ofunc/src/vobject.c

@@ -1,4 +1,5 @@
 #include "__ofunc.h"
+
 typedef void (*base_opt)(FUNC_VOBJ);
 
 #define OPERATION_DEFAULT(M_NAME_, ERR_NAME) do{ if (is_left) {runOperationFromValue(right, left, right, inter->data.mag_func[M_##M_NAME_], LINEFILE, CNEXT_NT);} else {setResultError(E_TypeException, CUL_ERROR(ERR_NAME), LINEFILE, true, CNEXT_NT);} }while(0)
@@ -13,11 +14,12 @@ void vobject_add_base(FUNC_VOBJ) {
         makeDouValue(left->value->data.dou.num + right->value->data.int_.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_dou && right->value->type == V_dou)
         makeDouValue(left->value->data.dou.num + right->value->data.dou.num, LINEFILE, CNEXT_NT);
-    else if(left->value->type == V_str && right->value->type == V_str){
+    else if (left->value->type == V_str && right->value->type == V_str) {
         wchar_t *new_string = memWidecat(left->value->data.str.str, right->value->data.str.str, false, false);
         makeStringValue(new_string, LINEFILE, CNEXT_NT);
         memFree(new_string);
-    } else OPERATION_DEFAULT(ADD, Add);
+    } else
+        OPERATION_DEFAULT(ADD, Add);
 }
 
 void vobject_sub_base(FUNC_VOBJ) {
@@ -31,8 +33,10 @@ void vobject_sub_base(FUNC_VOBJ) {
     else if (left->value->type == V_dou && right->value->type == V_dou)
         makeDouValue(left->value->data.dou.num - right->value->data.dou.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_pointer && right->value->type == V_pointer)
-        makeIntValue((char *)left->value->data.pointer.pointer - (char *)right->value->data.pointer.pointer, LINEFILE, CNEXT_NT);
-    else OPERATION_DEFAULT(SUB, Sub);
+        makeIntValue((char *) left->value->data.pointer.pointer - (char *) right->value->data.pointer.pointer, LINEFILE,
+                     CNEXT_NT);
+    else
+        OPERATION_DEFAULT(SUB, Sub);
 }
 
 void vobject_mul_base(FUNC_VOBJ) {
@@ -45,58 +49,70 @@ void vobject_mul_base(FUNC_VOBJ) {
         makeDouValue(left->value->data.dou.num * right->value->data.int_.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_dou && right->value->type == V_dou)
         makeDouValue(left->value->data.dou.num * right->value->data.dou.num, LINEFILE, CNEXT_NT);
-    else if(left->value->type == V_int && right->value->type == V_str) {
+    else if (left->value->type == V_int && right->value->type == V_str) {
         Value *tmp = left->value;
         left->value = right->value;
         right->value = tmp;
         goto mul_str;
-    } else if(left->value->type == V_str && right->value->type == V_int) mul_str: {
-        wchar_t *new_string = memWidecpySelf(left->value->data.str.str, right->value->data.int_.num);
-        makeStringValue(new_string, LINEFILE, CNEXT_NT);
-        memFree(new_string);
-    } else OPERATION_DEFAULT(MUL, Mul);
+    } else if (left->value->type == V_str && right->value->type == V_int)
+        mul_str:
+        {
+            wchar_t *new_string = memWidecpySelf(left->value->data.str.str, right->value->data.int_.num);
+            makeStringValue(new_string, LINEFILE, CNEXT_NT);
+            memFree(new_string);
+        }
+    else
+        OPERATION_DEFAULT(MUL, Mul);
 }
 
 void vobject_div_base(FUNC_VOBJ) {
     setResultCore(result);
-    if (right->value->type == V_int && right->value->data.int_.num == 0 || right->value->type == V_dou && !(right->value->data.dou.num != 0))  // !(right->value->data.dou.num != 0) 因为long double检查是否位0时容易出错
+    if (right->value->type == V_int && right->value->data.int_.num == 0 || right->value->type == V_dou &&
+                                                                           !(right->value->data.dou.num !=
+                                                                             0))  // !(right->value->data.dou.num != 0) 因为long double检查是否位0时容易出错
         setResultError(E_ValueException, L"divisor mustn't be 0", LINEFILE, true, CNEXT_NT);
     else if (left->value->type == V_int && right->value->type == V_int) {
         lldiv_t div_result = lldiv(left->value->data.int_.num, right->value->data.int_.num);
         makeIntValue(div_result.quot, LINEFILE, CNEXT_NT);
     } else if (left->value->type == V_dou && right->value->type == V_int)
-        makeDouValue(left->value->data.dou.num / (vdou)right->value->data.int_.num, LINEFILE, CNEXT_NT);
+        makeDouValue(left->value->data.dou.num / (vdou) right->value->data.int_.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_int && right->value->type == V_dou)
-        makeDouValue((vdou)left->value->data.int_.num / right->value->data.dou.num, LINEFILE, CNEXT_NT);
+        makeDouValue((vdou) left->value->data.int_.num / right->value->data.dou.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_dou && right->value->type == V_dou)
         makeDouValue(left->value->data.dou.num / right->value->data.dou.num, LINEFILE, CNEXT_NT);
-    else OPERATION_DEFAULT(DIV, Div);
+    else
+        OPERATION_DEFAULT(DIV, Div);
 }
 
 void vobject_intdiv_base(FUNC_VOBJ) {
     setResultCore(result);
-    if (right->value->type == V_int && right->value->data.int_.num == 0 || right->value->type == V_dou && (vint)right->value->data.dou.num == 0)  // !(right->value->data.dou.num != 0) 因为long double检查是否位0时容易出错
+    if (right->value->type == V_int && right->value->data.int_.num == 0 || right->value->type == V_dou &&
+                                                                           (vint) right->value->data.dou.num ==
+                                                                           0)  // !(right->value->data.dou.num != 0) 因为long double检查是否位0时容易出错
         setResultError(E_TypeException, L"divisor mustn't be 0", LINEFILE, true, CNEXT_NT);
     else if (left->value->type == V_int && right->value->type == V_int) {
         lldiv_t div_result = lldiv(left->value->data.int_.num, right->value->data.int_.num);
         makeIntValue(div_result.quot, LINEFILE, CNEXT_NT);
     } else if (left->value->type == V_dou && right->value->type == V_int)
-        makeIntValue((vint)left->value->data.dou.num / right->value->data.int_.num, LINEFILE, CNEXT_NT);
+        makeIntValue((vint) left->value->data.dou.num / right->value->data.int_.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_int && right->value->type == V_dou)
-        makeIntValue(left->value->data.int_.num / (vint)right->value->data.dou.num, LINEFILE, CNEXT_NT);
+        makeIntValue(left->value->data.int_.num / (vint) right->value->data.dou.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_dou && right->value->type == V_dou)
-        makeIntValue((vint)left->value->data.dou.num / (vint)right->value->data.dou.num, LINEFILE, CNEXT_NT);
-    else OPERATION_DEFAULT(INTDIV, Int Div);
+        makeIntValue((vint) left->value->data.dou.num / (vint) right->value->data.dou.num, LINEFILE, CNEXT_NT);
+    else
+        OPERATION_DEFAULT(INTDIV, Int Div);
 }
 
 void vobject_mod_base(FUNC_VOBJ) {
     setResultCore(result);
-    if (right->value->type == V_int && right->value->data.int_.num == 0)  // !(right->value->data.dou.num != 0) 因为long double检查是否位0时容易出错
+    if (right->value->type == V_int &&
+        right->value->data.int_.num == 0)  // !(right->value->data.dou.num != 0) 因为long double检查是否位0时容易出错
         setResultError(E_TypeException, L"divisor mustn't be 0", LINEFILE, true, CNEXT_NT);
     else if (left->value->type == V_int && right->value->type == V_int) {
         lldiv_t div_result = lldiv(left->value->data.int_.num, right->value->data.int_.num);
         makeIntValue(div_result.rem, LINEFILE, CNEXT_NT);
-    } else OPERATION_DEFAULT(MOD, Mod);
+    } else
+        OPERATION_DEFAULT(MOD, Mod);
 }
 
 void vobject_pow_base(FUNC_VOBJ) {
@@ -132,10 +148,12 @@ void vobject_eq_base(FUNC_VOBJ) {
     else if (left->value->type == V_dou && right->value->type == V_dou)
         makeBoolValue(left->value->data.dou.num == right->value->data.dou.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_pointer && right->value->type == V_pointer)
-        makeBoolValue((char *)left->value->data.pointer.pointer == (char *)right->value->data.pointer.pointer, LINEFILE, CNEXT_NT);
+        makeBoolValue((char *) left->value->data.pointer.pointer == (char *) right->value->data.pointer.pointer,
+                      LINEFILE, CNEXT_NT);
     else if (left->value->type == V_str && right->value->type == V_str)
         makeBoolValue(eqWide(left->value->data.str.str, left->value->data.str.str), LINEFILE, CNEXT_NT);
-    else OPERATION_DEFAULT(EQ, Eq);
+    else
+        OPERATION_DEFAULT(EQ, Eq);
 }
 
 void vobject_noteq_base(FUNC_VOBJ) {
@@ -149,10 +167,12 @@ void vobject_noteq_base(FUNC_VOBJ) {
     else if (left->value->type == V_dou && right->value->type == V_dou)
         makeBoolValue(left->value->data.dou.num != right->value->data.dou.num, LINEFILE, CNEXT_NT);
     else if (left->value->type == V_pointer && right->value->type == V_pointer)
-        makeBoolValue((char *)left->value->data.pointer.pointer != (char *)right->value->data.pointer.pointer, LINEFILE, CNEXT_NT);
+        makeBoolValue((char *) left->value->data.pointer.pointer != (char *) right->value->data.pointer.pointer,
+                      LINEFILE, CNEXT_NT);
     else if (left->value->type == V_str && right->value->type == V_str)
         makeBoolValue(!(eqWide(left->value->data.str.str, left->value->data.str.str)), LINEFILE, CNEXT_NT);
-    else OPERATION_DEFAULT(NOTEQ, Not Eq);
+    else
+        OPERATION_DEFAULT(NOTEQ, Not Eq);
 }
 
 #define BITMACRO(SYMBOL, M_NAME_, NAME, TYPE) void vobject_##NAME##_base(FUNC_VOBJ) { \
@@ -163,8 +183,11 @@ void vobject_noteq_base(FUNC_VOBJ) {
 }
 
 BITMACRO(&, BAND, band, Bit And)
+
 BITMACRO(|, BOR, bor, Bit Or)
+
 BITMACRO(^, BXOR, bxor, Bit Xor)
+
 #undef BITMACRO
 
 #define BITMOVEMACRO(SYMBOL1, SYMBOL2, M_NAME_, NAME, TYPE) void vobject_##NAME##_base(FUNC_VOBJ) { \
@@ -178,7 +201,9 @@ BITMACRO(^, BXOR, bxor, Bit Xor)
 }
 
 BITMOVEMACRO(<<, >>, BL, bl, Bit Left)
+
 BITMOVEMACRO(>>, <<, BR, br, Bit Right)
+
 #undef BITMOVEMACRO
 
 #define COMPAREMACRO(SYMBOL, M_NAME_, NAME, TYPE) void vobject_##NAME##_base(FUNC_VOBJ) { \
@@ -197,12 +222,16 @@ BITMOVEMACRO(>>, <<, BR, br, Bit Right)
 }
 
 COMPAREMACRO(>, MORE, more, More)
+
 COMPAREMACRO(>=, MOREEQ, moreeq, More Eq)
+
 COMPAREMACRO(<=, LESSEQ, lesseq, Less Eq)
+
 COMPAREMACRO(<, LESS, less, Less Eq)
+
 #undef COMPAREMACRO
 
-static ResultType vobject_opt_core(O_FUNC, base_opt func){
+static ResultType vobject_opt_core(O_FUNC, base_opt func) {
     LinkValue *left;
     LinkValue *right;
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
@@ -220,29 +249,49 @@ static ResultType vobject_opt_core(O_FUNC, base_opt func){
     left = ap[1].value;
     right = ap[2].value;
 
-    func(CFUNC_VOBJ(var_list, result, belong, left, right, (ap[0].value->value == left->value)));  // 如果 (ap[0].value->value == left->value) 为 true 则代表 is_left 模式
+    func(CFUNC_VOBJ(var_list, result, belong, left, right, (ap[0].value->value ==
+                                                            left->value)));  // 如果 (ap[0].value->value == left->value) 为 true 则代表 is_left 模式
     return result->type;
 }
 
 #define COMPAREFUNCMACRO(TYPE) ResultType vobject_##TYPE(O_FUNC){ return vobject_opt_core(CO_FUNC(arg, var_list, result, belong), vobject_##TYPE##_base); }
+
 COMPAREFUNCMACRO(add)
+
 COMPAREFUNCMACRO(sub)
+
 COMPAREFUNCMACRO(mul)
+
 COMPAREFUNCMACRO(div)
+
 COMPAREFUNCMACRO(intdiv)
+
 COMPAREFUNCMACRO(mod)
+
 COMPAREFUNCMACRO(pow)
+
 COMPAREFUNCMACRO(eq)
+
 COMPAREFUNCMACRO(noteq)
+
 COMPAREFUNCMACRO(moreeq)
+
 COMPAREFUNCMACRO(lesseq)
+
 COMPAREFUNCMACRO(more)
+
 COMPAREFUNCMACRO(less)
+
 COMPAREFUNCMACRO(band)
+
 COMPAREFUNCMACRO(bor)
+
 COMPAREFUNCMACRO(bxor)
+
 COMPAREFUNCMACRO(bl)
+
 COMPAREFUNCMACRO(br)
+
 #undef COMPAREFUNCMACRO
 
 void vobject_negate_base(FUNC_VOBJR) {
@@ -276,7 +325,7 @@ void vobject_bnot_base(FUNC_VOBJR) {
     setResultCore(result);
     switch (left->value->type) {
         case V_int:
-            makeIntValue(~(unsigned long long)(left->value->data.int_.num), LINEFILE, CNEXT_NT);
+            makeIntValue(~(unsigned long long) (left->value->data.int_.num), LINEFILE, CNEXT_NT);
             break;
         case V_bool:
             makeBoolValue(!(left->value->data.bool_.bool_), LINEFILE, CNEXT_NT);
@@ -290,7 +339,7 @@ void vobject_bnot_base(FUNC_VOBJR) {
     }
 }
 
-static ResultType vobject_negate(O_FUNC){
+static ResultType vobject_negate(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=name_value, .name=L"val", .must=1, .long_arg=false},
                            {.must=-1}};
@@ -304,7 +353,7 @@ static ResultType vobject_negate(O_FUNC){
     return result->type;
 }
 
-static ResultType vobject_bnot(O_FUNC){
+static ResultType vobject_bnot(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=name_value, .name=L"val", .must=1, .long_arg=false},
                            {.must=-1}};
@@ -318,7 +367,7 @@ static ResultType vobject_bnot(O_FUNC){
     return result->type;
 }
 
-static ResultType vobject_bool(O_FUNC){
+static ResultType vobject_bool(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     bool result_ = false;
@@ -370,7 +419,7 @@ static ResultType vobject_bool(O_FUNC){
     return result->type;
 }
 
-static ResultType vobject_repo(O_FUNC){
+static ResultType vobject_repo(O_FUNC) {
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     wchar_t *repo = NULL;
@@ -382,21 +431,21 @@ static ResultType vobject_repo(O_FUNC){
     freeResult(result);
     value = ap[0].value->value;
 
-    switch (value->type){  // node和list以及dict都不再此处设定
+    switch (value->type) {  // node和list以及dict都不再此处设定
         case V_int: {
-            char str[30] = { NUL };
+            char str[30] = {NUL};
             snprintf(str, 30, "%lld", value->data.int_.num);
             repo = memStrToWcs(str, false);
             break;
         }
         case V_pointer: {
-            char str[30] = { NUL };
+            char str[30] = {NUL};
             snprintf(str, 30, "%p", value->data.pointer.pointer);
             repo = memStrToWcs(str, false);
             break;
         }
         case V_dou: {
-            char str[30] = { NUL };
+            char str[30] = {NUL};
             if (value->data.dou.num != 0)
                 snprintf(str, 30, "%Lg", value->data.dou.num);
             else
@@ -408,13 +457,13 @@ static ResultType vobject_repo(O_FUNC){
             repo = memWidecpy(value->data.str.str);
             break;
         case V_func: {
-            char str[30] = { NUL };
+            char str[30] = {NUL};
             snprintf(str, 30, "(func on %p)", value);
             repo = memStrToWcs(str, false);
             break;
         }
         case V_class: {
-            char str[30] = { NUL };
+            char str[30] = {NUL};
             snprintf(str, 30, "(class on %p)", value);
             repo = memStrToWcs(str, false);
             break;
@@ -436,7 +485,7 @@ static ResultType vobject_repo(O_FUNC){
             break;
         }
         default:
-            setResultError(E_TypeException, CUL_ERROR(repo/str), LINEFILE, true, CNEXT_NT);
+            setResultError(E_TypeException, CUL_ERROR(repo / str), LINEFILE, true, CNEXT_NT);
             return R_error;
     }
     makeStringValue(repo, LINEFILE, CNEXT_NT);
@@ -444,35 +493,35 @@ static ResultType vobject_repo(O_FUNC){
     return result->type;
 }
 
-void registeredVObject(R_FUNC){
+void registeredVObject(R_FUNC) {
     LinkValue *object = inter->data.base_obj[B_VOBJECT];
-    NameFunc tmp[] = {{inter->data.mag_func[M_ADD], vobject_add, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_SUB], vobject_sub, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MUL], vobject_mul, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DIV], vobject_div, fp_obj, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_ADD],    vobject_add,    fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_SUB],    vobject_sub,    fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MUL],    vobject_mul,    fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DIV],    vobject_div,    fp_obj, .var=nfv_notpush},
                       {inter->data.mag_func[M_INTDIV], vobject_intdiv, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MOD], vobject_mod, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_POW], vobject_pow, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MOD],    vobject_mod,    fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_POW],    vobject_pow,    fp_obj, .var=nfv_notpush},
 
-                      {inter->data.mag_func[M_EQ], vobject_eq, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NOTEQ], vobject_noteq, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_EQ],     vobject_eq,     fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NOTEQ],  vobject_noteq,  fp_obj, .var=nfv_notpush},
                       {inter->data.mag_func[M_MOREEQ], vobject_moreeq, fp_obj, .var=nfv_notpush},
                       {inter->data.mag_func[M_LESSEQ], vobject_lesseq, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MORE], vobject_more, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_LESS], vobject_less, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_MORE],   vobject_more,   fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_LESS],   vobject_less,   fp_obj, .var=nfv_notpush},
 
-                      {inter->data.mag_func[M_BAND], vobject_band, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BOR], vobject_bor, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BXOR], vobject_bxor, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BL], vobject_bl, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BR], vobject_br, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BAND],   vobject_band,   fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BOR],    vobject_bor,    fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BXOR],   vobject_bxor,   fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BL],     vobject_bl,     fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BR],     vobject_br,     fp_obj, .var=nfv_notpush},
 
                       {inter->data.mag_func[M_NEGATE], vobject_negate, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BNOT], vobject_bnot, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BNOT],   vobject_bnot,   fp_obj, .var=nfv_notpush},
 
-                      {inter->data.mag_func[M_BOOL], vobject_bool, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_REPO], vobject_repo, fp_obj, .var=nfv_notpush},
-                      {inter->data.mag_func[M_STR], vobject_repo, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_BOOL],   vobject_bool,   fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_REPO],   vobject_repo,   fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_STR],    vobject_repo,   fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"vobject", object, belong, inter);
@@ -480,7 +529,7 @@ void registeredVObject(R_FUNC){
     gc_freeTmpLink(&object->gc_status);
 }
 
-void makeBaseVObject(Inter *inter){
+void makeBaseVObject(Inter *inter) {
     LinkValue *vobject = makeBaseChildClass(inter->data.base_obj[B_OBJECT], inter);
     gc_addStatementLink(&vobject->gc_status);
     inter->data.base_obj[B_VOBJECT] = vobject;

+ 1 - 1
vmcore/parser/include/__grammar.h

@@ -5,7 +5,7 @@
 #define P_FUNC ParserMessage *pm, Inter *inter /*pasers函数的统一签名*/
 #define CP_FUNC pm, inter /*pasers函数调用的统一实参*/
 
-#define addStatementToken(type, st, pm) addBackToken(pm->tm->ts, makeStatementToken(type, st))
+#define addStatementToken(type, st, pm) addBackToken((pm)->tm->ts, makeStatementToken(type, st))
 #define delToken(pm) (freeToken(popNewToken(pm->tm), false))
 #define backToken_(pm, token) addBackToken(pm->tm->ts, (token))
 #define addLexToken(pm, type) backToken_(pm, makeLexToken(type, NULL, NULL, 0))

+ 4 - 6
vmcore/src/runbranch.c

@@ -26,8 +26,7 @@ static void newBranchYield(Statement *branch_st, Statement *node, StatementList
     branch_st->info.have_info = true;
 }
 
-static void newWithBranchYield(Statement *branch_st, Statement *node, StatementList *sl_node, VarList *new_var, enum StatementInfoStatus status,
-                        Inter *inter, LinkValue *value, LinkValue *_exit_, LinkValue *_enter_, LinkValue *with){
+static void newWithBranchYield(Statement *branch_st, Statement *node, StatementList *sl_node, enum StatementInfoStatus status, LinkValue *value, LinkValue *_exit_, LinkValue *_enter_, LinkValue *with, VarList *new_var){
     newBranchYield(branch_st, node, sl_node, new_var, status);
     branch_st->info.branch.with_.value = value;
     branch_st->info.branch.with_._exit_ = _exit_;
@@ -35,8 +34,7 @@ static void newWithBranchYield(Statement *branch_st, Statement *node, StatementL
     branch_st->info.branch.with_.with_belong = with;
 }
 
-static void newForBranchYield(Statement *branch_st, Statement *node, StatementList *sl_node, VarList *new_var, enum StatementInfoStatus status,
-                        Inter *inter, LinkValue *iter){
+static void newForBranchYield(Statement *branch_st, Statement *node, StatementList *sl_node, enum StatementInfoStatus status, LinkValue *iter, VarList *new_var){
     newBranchYield(branch_st, node, sl_node, new_var, status);
     branch_st->info.branch.for_.iter = iter;
     gc_addTmpLink(&iter->gc_status);
@@ -450,7 +448,7 @@ static void setForResult(bool yield_run, StatementList *sl, Statement *st, Resul
         else
             freeRunInfo(st, false);
     } else if (result->type == R_yield)
-        newForBranchYield(st, result->node, sl, var_list, status, inter, iter);
+        newForBranchYield(st, result->node, sl, status, iter, var_list);
     // else - 正常模式, 不作任何操作
 }
 
@@ -644,7 +642,7 @@ static void setWithResult(bool yield_run, StatementList *sl, Statement *st, Resu
         if (status == info_finally_branch)
             newBranchYield(st, result->node, sl, NULL, status);
         else
-            newWithBranchYield(st, result->node, sl, var_list, status, inter, value, _exit_, _enter_, with);
+            newWithBranchYield(st, result->node, sl, status, value, _exit_, _enter_, with, var_list);
     }  // else - 即正常模式, 不需要任何处理
 }
 

+ 0 - 1
vmcore/src/runfile.c

@@ -64,7 +64,6 @@ int checkFileDir(char **file_dir, FUNC) {
         return 1;
 
     {
-        char *getcwd(char *buf,size_t size);
         char arr_cwd[200];
         char *p_cwd = NULL;
         getcwd(arr_cwd, 200);