瀏覽代碼

feat: 添加六种新的函数特殊形参类型

实参允许添加三个特殊参数值
SongZihuan 4 年之前
父節點
當前提交
2657fb918e

+ 21 - 10
vmcore/include/value.h

@@ -87,16 +87,27 @@ struct Function{
     void (*ffunc)();  // ffi导入的func
     struct {
         enum FunctionPtType {
-            free_,  // 不包含任何隐式传递的参数
-            static_,  // 不包含self参数
-            object_static_,  // self参数不允许class
-            class_static_,  // self参数允许一切,但转换为类
-            all_static_, // self参数允许一切
-            cls_static_,  // 使用function自带的cls作为参数
-            object_free_,  // 同object_static_但不包含func参数
-            class_free_,  // 同object_static_但不包含func参数
-            all_free_,  // 允许class或者object
-            cls_free_,  // 使用function自带的cls作为参数
+            fp_no_,  // 不包含任何隐式传递的参数
+            fp_func_,  // 不包含self参数
+            fp_func_obj,  // self参数不允许class
+            fp_func_class,  // self参数允许一切,但转换为类
+            fp_func_all, // self参数允许一切
+            fp_func_cls,  // 使用function自带的cls作为参数
+            fp_obj,  // 同object_static_但不包含func参数
+            fp_class,  // 同object_static_但不包含func参数
+            fp_all,  // 允许class或者object
+            fp_cls,  // 使用function自带的cls作为参数
+
+            // 组合
+            fp_func_cls_obj,
+            fp_func_cls_class,
+            fp_func_cls_all,
+
+            fp_cls_obj,
+            fp_cls_class,
+            fp_cls_all,
+            // obj和class没有同时存在的意义, 可以使用内置函数直接获取obj所对应的class
+            // 直接设定class的目的是修饰类方法
         } pt_type;
         LinkValue *cls;
         bool run;  // 是否为即时调用

+ 1 - 1
vmcore/ofunc/src/__ofunc.c

@@ -39,7 +39,7 @@ bool iterClassFunc(NameFunc *list, FUNC_NT){
 
     setResultCore(result);
     object_var->next = var_list;
-    inter->data.default_pt_type = object_free_;
+    inter->data.default_pt_type = fp_func_obj;
 
     for (PASS; list->of != NULL; list++) {
         LinkValue *value = registeredFunctionCore(list->of, list->name, list->var, CFUNC_NT(object_var, result, belong));

+ 2 - 2
vmcore/ofunc/src/bool.c

@@ -53,8 +53,8 @@ ResultType bool_init(O_FUNC){
 
 void registeredBool(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_BOOL];
-    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], bool_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], bool_init, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], bool_new,   fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], bool_init, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"bool", object, belong, inter);

+ 8 - 8
vmcore/ofunc/src/dict.c

@@ -246,14 +246,14 @@ ResultType dict_str(O_FUNC){
 
 void registeredDict(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_DICT];
-    NameFunc tmp[] = {{L"keys", dict_keys, object_free_},
-                      {inter->data.mag_func[M_NEW], dict_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DOWN], dict_down, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_ITER], dict_iter, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_REPO], dict_repo, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_STR], dict_str, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DOWN_ASSIGMENT], dict_down_assignment, object_free_},
-                      {inter->data.mag_func[M_DOWN_DEL], dict_down_del, object_free_},
+    NameFunc tmp[] = {{L"keys", dict_keys,                                           fp_obj},
+                      {inter->data.mag_func[M_NEW], dict_new,                        fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DOWN], dict_down,                      fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_ITER], dict_iter,                      fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_REPO], dict_repo,                      fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_STR], dict_str,                        fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DOWN_ASSIGMENT], dict_down_assignment, fp_obj},
+                      {inter->data.mag_func[M_DOWN_DEL], dict_down_del,              fp_obj},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"dict", object, belong, inter);

+ 3 - 3
vmcore/ofunc/src/dictiter.c

@@ -124,9 +124,9 @@ ResultType dictiter_down(O_FUNC){
 
 void registeredDictIter(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_DICTITER];
-    NameFunc tmp[] = {{inter->data.mag_func[M_INIT], dictiter_init, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NEXT], dictiter_next, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DOWN], dictiter_down, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_INIT], dictiter_init, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NEXT], dictiter_next, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DOWN], dictiter_down, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"dictiter", object, belong, inter);

+ 2 - 2
vmcore/ofunc/src/dou.c

@@ -73,8 +73,8 @@ ResultType dou_init(O_FUNC){
 
 void registeredDou(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_DOU];
-    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], dou_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], dou_init, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], dou_new, fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], dou_init, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"dou", object, belong, inter);

+ 1 - 1
vmcore/ofunc/src/error_.c

@@ -45,7 +45,7 @@ void registeredExcIter(R_FUNC){
                    {NULL, NULL}};
     {
         LinkValue *object = inter->data.base_exc[E_BaseException];
-        NameFunc tmp[] = {{L"__init__", base_exception_init, object_free_, .var=nfv_notpush},
+        NameFunc tmp[] = {{L"__init__", base_exception_init, fp_obj, .var=nfv_notpush},
                           {NULL, NULL}};
         gc_addTmpLink(&object->gc_status);
         addBaseClassVar(L"BaseException", object, belong, inter);

+ 14 - 14
vmcore/ofunc/src/file_.c

@@ -354,20 +354,20 @@ ResultType file_enter(O_FUNC){
 
 void registeredFile(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_FILE];
-    NameFunc tmp[] = {{L"read", file_read, object_free_, .var=nfv_notpush},
-                      {L"write", file_write, object_free_, .var=nfv_notpush},
-                      {L"close", file_close, object_free_, .var=nfv_notpush},
-                      {L"get_seek", file_get_seek, object_free_, .var=nfv_notpush},
-                      {L"seek", file_seek, object_free_, .var=nfv_notpush},
-                      {L"readline", file_readline, object_free_, .var=nfv_notpush},
-                      {L"end", file_isend, object_free_, .var=nfv_notpush},
-                      {L"err", file_iserr, object_free_, .var=nfv_notpush},
-                      {L"clean", file_clean_err, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_ENTER], file_enter, object_free_, .var=nfv_notpush},
-//                      {inter->data.mag_func[M_DEL], file_close, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_EXIT], file_close, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NEW], file_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], file_init, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{L"read", file_read, fp_obj, .var=nfv_notpush},
+                      {L"write", file_write, fp_obj, .var=nfv_notpush},
+                      {L"close", file_close, fp_obj, .var=nfv_notpush},
+                      {L"get_seek", file_get_seek, fp_obj, .var=nfv_notpush},
+                      {L"seek", file_seek, fp_obj, .var=nfv_notpush},
+                      {L"readline", file_readline, fp_obj, .var=nfv_notpush},
+                      {L"end", file_isend, fp_obj, .var=nfv_notpush},
+                      {L"err", file_iserr, fp_obj, .var=nfv_notpush},
+                      {L"clean", file_clean_err, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_ENTER], file_enter, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DEL], file_close, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_EXIT], file_close, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NEW], file_new, fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], file_init, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"file", object, belong, inter);

+ 4 - 4
vmcore/ofunc/src/function.c

@@ -55,7 +55,7 @@ ResultType function_init(O_FUNC){
     if (ap[1].value != NULL) {
         Statement *return_ = makeBaseLinkValueStatement(ap[1].value, LINEFILE);
         func->value->data.function.function = makeReturnStatement(return_, LINEFILE);
-        func->value->data.function.function_data.pt_type = free_;
+        func->value->data.function.function_data.pt_type = fp_no_;
         func->value->data.function.type = vm_func;
     }
 
@@ -96,8 +96,8 @@ ResultType function_set(O_FUNC){  // 针对FFI设置vaargs
 
 void registeredFunction(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_FUNCTION];
-    NameFunc tmp[] = {{L"set", function_set, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], function_init, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{L"set", function_set, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], function_init, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"func", object, belong, inter);
@@ -118,7 +118,7 @@ void functionPresetting(LinkValue *func, Inter *inter) {  // 提前注册func_ne
     setResultCore(&result);
 
     func_new = makeCFunctionFromOf(function_new, func, function_new, func, NULL, inter);  // var_list为NULL, 即声明为内联函数 (若不声明为内联函数则改为inter.var_list即可)
-    func_new->value->data.function.function_data.pt_type = class_free_;
+    func_new->value->data.function.function_data.pt_type = fp_class;
     addStrVar(inter->data.mag_func[M_NEW], false, true, func_new, LINEFILE, false, CFUNC_NT(object_var, &result, func));
     freeResult(&result);
     freeResult(&result);

+ 2 - 2
vmcore/ofunc/src/int.c

@@ -73,8 +73,8 @@ ResultType int_init(O_FUNC){
 
 void registeredInt(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_INT_];
-    NameFunc tmp[] = {{inter->data.mag_func[M_NEW],  int_new,  class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], int_init, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_NEW],  int_new,  fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], int_init, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"int", object, belong, inter);

+ 2 - 2
vmcore/ofunc/src/io.c

@@ -53,8 +53,8 @@ ResultType vm_input(O_FUNC){
 }
 
 void registeredIOFunction(R_FUNC){
-    NameFunc tmp[] = {{L"print", vm_print, free_, .var=nfv_notpush},
-                      {L"input", vm_input, free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{L"print", vm_print, fp_no_, .var=nfv_notpush},
+                      {L"input", vm_input, fp_no_, .var=nfv_notpush},
                       {NULL, NULL}};
     iterBaseNameFunc(tmp, belong, CFUNC_CORE(var_list));
 }

+ 6 - 6
vmcore/ofunc/src/lib_.c

@@ -172,12 +172,12 @@ ResultType lib_attr(O_FUNC){
 
 void registeredLib(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_LIB];
-    NameFunc tmp[] = {{L"close", lib_close, object_free_, .var=nfv_notpush},
-                      {L"add", lib_add, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NEW], lib_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], lib_init, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DEL], lib_close, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_ATTR], lib_attr, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{L"close", lib_close, fp_obj, .var=nfv_notpush},
+                      {L"add", lib_add, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NEW], lib_new, fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], lib_init, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DEL], lib_close, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_ATTR], lib_attr, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"clib", object, belong, inter);

+ 11 - 11
vmcore/ofunc/src/list.c

@@ -419,14 +419,14 @@ ResultType list_str(O_FUNC){
 void registeredList(R_FUNC){
     {
         LinkValue *object = inter->data.base_obj[B_TUPLE];
-        NameFunc tmp[] = {{inter->data.mag_func[M_NEW], tuple_new, class_free_},
-                          {inter->data.mag_func[M_DOWN], list_down, object_free_},
-                          {inter->data.mag_func[M_SLICE], list_slice, object_free_},
-                          {inter->data.mag_func[M_ITER], list_iter, object_free_},
-                          {inter->data.mag_func[M_REPO], list_repo, object_free_},
-                          {inter->data.mag_func[M_STR], list_str, object_free_},
-                          {inter->data.mag_func[M_DOWN_DEL], list_down_del, object_free_},
-                          {inter->data.mag_func[M_SLICE_DEL], list_slice_del, object_free_},
+        NameFunc tmp[] = {{inter->data.mag_func[M_NEW], tuple_new, fp_class},
+                          {inter->data.mag_func[M_DOWN], list_down, fp_obj},
+                          {inter->data.mag_func[M_SLICE], list_slice, fp_obj},
+                          {inter->data.mag_func[M_ITER], list_iter, fp_obj},
+                          {inter->data.mag_func[M_REPO], list_repo, fp_obj},
+                          {inter->data.mag_func[M_STR], list_str, fp_obj},
+                          {inter->data.mag_func[M_DOWN_DEL], list_down_del, fp_obj},
+                          {inter->data.mag_func[M_SLICE_DEL], list_slice_del, fp_obj},
                           {NULL, NULL}};
         gc_addTmpLink(&object->gc_status);
         addBaseClassVar(L"tuple", object, belong, inter);
@@ -436,9 +436,9 @@ void registeredList(R_FUNC){
 
     {
         LinkValue *object = inter->data.base_obj[B_LIST];
-        NameFunc tmp[] = {{inter->data.mag_func[M_NEW], list_new, class_free_, .var=nfv_notpush},
-                          {inter->data.mag_func[M_DOWN_ASSIGMENT], list_down_assignment, object_free_, .var=nfv_notpush},
-                          {inter->data.mag_func[M_SLICE_ASSIGMENT], list_slice_assignment, object_free_, .var=nfv_notpush},
+        NameFunc tmp[] = {{inter->data.mag_func[M_NEW], list_new, fp_class, .var=nfv_notpush},
+                          {inter->data.mag_func[M_DOWN_ASSIGMENT], list_down_assignment, fp_obj, .var=nfv_notpush},
+                          {inter->data.mag_func[M_SLICE_ASSIGMENT], list_slice_assignment, fp_obj, .var=nfv_notpush},
                           {NULL, NULL}};
         gc_addTmpLink(&object->gc_status);
         addBaseClassVar(L"list", object, belong, inter);

+ 2 - 2
vmcore/ofunc/src/listiter.c

@@ -90,8 +90,8 @@ ResultType listiter_next(O_FUNC){
 
 void registeredListIter(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_LISTITER];
-    NameFunc tmp[] = {{inter->data.mag_func[M_INIT], listiter_init, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NEXT], listiter_next, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_INIT], listiter_init, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NEXT], listiter_next, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"listiter", object, belong, inter);

+ 3 - 3
vmcore/ofunc/src/object.c

@@ -73,9 +73,9 @@ ResultType object_str(O_FUNC){
 
 void registeredObject(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_OBJECT];
-    NameFunc tmp[] = {{inter->data.mag_func[M_NEW],  object_new,  class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_REPO], object_repo, all_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_STR],  object_str,  all_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_NEW],  object_new,  fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_REPO], object_repo, fp_all, .var=nfv_notpush},
+                      {inter->data.mag_func[M_STR],  object_str,  fp_all, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"object", object, belong, inter);

+ 1 - 1
vmcore/ofunc/src/pass.c

@@ -27,7 +27,7 @@ ResultType pass_new(O_FUNC){
 
 void registeredEllipisis(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_PASS];
-    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], pass_new, class_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], pass_new, fp_class, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"ellipsis", object, belong, inter);

+ 2 - 2
vmcore/ofunc/src/pointer.c

@@ -53,8 +53,8 @@ ResultType pointer_init(O_FUNC){
 
 void registeredPointer(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_POINTER];
-    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], pointer_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], pointer_init, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{inter->data.mag_func[M_NEW], pointer_new, fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], pointer_init, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"pointer", object, belong, inter);

+ 9 - 9
vmcore/ofunc/src/str.c

@@ -192,13 +192,13 @@ ResultType str_iter(O_FUNC){
 
 void registeredStr(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_STR];
-    NameFunc tmp[] = {{L"to_list", str_to_list, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NEW], str_new, class_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INIT], str_init, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_SLICE], str_slice, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_ITER], str_iter, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DOWN], str_down, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_SLICE], str_slice, object_free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{L"to_list", str_to_list, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_NEW], str_new, fp_class, .var=nfv_notpush},
+                      {inter->data.mag_func[M_INIT], str_init, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_SLICE], str_slice, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_ITER], str_iter, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_DOWN], str_down, fp_obj, .var=nfv_notpush},
+                      {inter->data.mag_func[M_SLICE], str_slice, fp_obj, .var=nfv_notpush},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     iterBaseClassFunc(tmp, object, CFUNC_CORE(inter->var_list));
@@ -261,8 +261,8 @@ void strFunctionPresetting(LinkValue *func, LinkValue *func_new, LinkValue *func
 
     new_func = makeFunctionFromValue(func, func_new, func_init, str_new, obj, NULL, inter);  // 声明为内联函数
     init_func = makeFunctionFromValue(func, func_new, func_init, str_init, obj, NULL, inter);
-    new_func->value->data.function.function_data.pt_type = class_free_;
-    init_func->value->data.function.function_data.pt_type = object_free_;
+    new_func->value->data.function.function_data.pt_type = fp_class;
+    init_func->value->data.function.function_data.pt_type = fp_obj;
 
 
     new_name = makeStrFromOf(obj, new_func, init_func, inter->data.mag_func[M_NEW], inter);

+ 77 - 46
vmcore/ofunc/src/sys.c

@@ -80,44 +80,68 @@ ResultType vm_setMethodCore(O_FUNC, enum FunctionPtType type){
     return R_opt;
 }
 
-ResultType vm_clsfreemethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), cls_free_);
+ResultType vm_cls(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_cls);
 }
 
-ResultType vm_clsmethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), cls_static_);
+ResultType vm_func_cls(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_cls);
 }
 
-ResultType vm_freemethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), free_);
+ResultType vm_no_(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_no_);
 }
 
-ResultType vm_staticmethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), static_);
+ResultType vm_func_(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_);
 }
 
-ResultType vm_classmethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), class_static_);
+ResultType vm_func_class(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_class);
 }
 
-ResultType vm_objectmethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), object_static_);
+ResultType vm_func_obj(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_obj);
 }
 
-ResultType vm_classfreemethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), class_free_);
+ResultType vm_class(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_class);
 }
 
-ResultType vm_objectfreemethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), object_free_);
+ResultType vm_obj(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_obj);
 }
 
-ResultType vm_allfreemethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), all_free_);
+ResultType vm_all(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_all);
 }
 
-ResultType vm_allstaticmethod(O_FUNC){
-    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), all_static_);
+ResultType vm_func_all(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_all);
+}
+
+ResultType vm_cls_obj(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_cls_obj);
+}
+
+ResultType vm_cls_class(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_cls_class);
+}
+
+ResultType vm_cls_all(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_cls_all);
+}
+
+ResultType vm_func_cls_obj(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_cls_obj);
+}
+
+ResultType vm_func_cls_class(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_cls_class);
+}
+
+ResultType vm_func_cls_all(O_FUNC){
+    return vm_setMethodCore(CO_FUNC(arg, var_list, result, belong), fp_func_cls_all);
 }
 
 ResultType vm_isnowrun(O_FUNC){
@@ -321,32 +345,39 @@ ResultType vm_exec(O_FUNC){
 }
 
 void registeredSysFunction(R_FUNC){
-    NameFunc tmp[] = {{L"super", vm_super, free_, .var=nfv_notpush},
-                      {L"freemethod", vm_freemethod, free_, .var=nfv_notpush},
-                      {L"staticmethod", vm_staticmethod, free_, .var=nfv_notpush},
-                      {L"staticclassmethod", vm_classmethod, free_, .var=nfv_notpush},
-                      {L"staticobjectmethod", vm_objectmethod, free_, .var=nfv_notpush},
-                      {L"classmethod", vm_classfreemethod, free_, .var=nfv_notpush},
-                      {L"objectmethod", vm_objectfreemethod, free_, .var=nfv_notpush},
-                      {L"simplemethod", vm_allfreemethod, free_, .var=nfv_notpush},
-                      {L"simplestaticmethod", vm_allstaticmethod, free_, .var=nfv_notpush},
-                      {L"clsmethod", vm_clsfreemethod, free_, .var=nfv_notpush},
-                      {L"clsstaticmethod", vm_clsmethod, free_, .var=nfv_notpush},
-                      {L"isnowrun", vm_isnowrun, free_, .var=nfv_notpush},
-                      {L"disnowrun", vm_disnowrun, free_, .var=nfv_notpush},
-                      {L"quit", vm_quit, free_, .var=nfv_notpush},
-                      {L"exec", vm_exec, free_, .var=nfv_notpush},
-                      {L"open", vm_open, free_, .var=nfv_notpush},
-                      {L"assert_ignore", vm_assertignore, free_, .var=nfv_notpush},
-                      {L"assert_run", vm_assertrun, free_, .var=nfv_notpush},
-                      {L"assert_raise", vm_assertraise, free_, .var=nfv_notpush},
-                      {L"selfun", vm_selfun, free_, .var=nfv_notpush},
-                      {L"nselfun", vm_nselfun, free_, .var=nfv_notpush},
-                      {L"free_mode", vm_freemode, free_, .var=nfv_notpush},
-                      {L"normal_mode", vm_nfreemode, free_, .var=nfv_notpush},
-                      {L"free_opt", vm_free_opt, free_, .var=nfv_notpush},
-                      {L"normal_opt", vm_normal_opt, free_, .var=nfv_notpush},
-                      {L"simple_opt", vm_simple_opt, free_, .var=nfv_notpush},
+    NameFunc tmp[] = {{L"super",              vm_super,        fp_no_, .var=nfv_notpush},
+                      {L"static_method",         vm_no_,          fp_no_, .var=nfv_notpush},
+                      {L"func_method",       vm_func_,        fp_no_, .var=nfv_notpush},
+                      {L"func_class_method",  vm_func_class,   fp_no_, .var=nfv_notpush},
+                      {L"func_obj_method", vm_func_obj,     fp_no_, .var=nfv_notpush},
+                      {L"class_method",        vm_class,        fp_no_, .var=nfv_notpush},
+                      {L"obj_method",       vm_obj,          fp_no_, .var=nfv_notpush},
+                      {L"simple_method",       vm_all,          fp_no_, .var=nfv_notpush},
+                      {L"func_simple_method", vm_func_all,     fp_no_, .var=nfv_notpush},
+                      {L"cls_method",          vm_cls,          fp_no_, .var=nfv_notpush},
+                      {L"func_cls_method",    vm_func_cls,     fp_no_, .var=nfv_notpush},
+                      {L"cls_obj_method", vm_cls_obj,     fp_no_, .var=nfv_notpush},
+                      {L"cls_class_method",          vm_cls_class,          fp_no_, .var=nfv_notpush},
+                      {L"cls_simple_method",    vm_cls_all,     fp_no_, .var=nfv_notpush},
+                      {L"func_cls_obj_method", vm_func_cls_obj,     fp_no_, .var=nfv_notpush},
+                      {L"func_cls_obj_method",          vm_func_cls_class,          fp_no_, .var=nfv_notpush},
+                      {L"func_cls_simple_method",    vm_func_cls_all,     fp_no_, .var=nfv_notpush},
+
+                      {L"is_now_run",           vm_isnowrun,     fp_no_, .var=nfv_notpush},
+                      {L"dis_now_run",          vm_disnowrun,    fp_no_, .var=nfv_notpush},
+                      {L"quit",               vm_quit,         fp_no_, .var=nfv_notpush},
+                      {L"exec",               vm_exec,         fp_no_, .var=nfv_notpush},
+                      {L"open",               vm_open,         fp_no_, .var=nfv_notpush},
+                      {L"assert_ignore",      vm_assertignore, fp_no_, .var=nfv_notpush},
+                      {L"assert_run",         vm_assertrun,    fp_no_, .var=nfv_notpush},
+                      {L"assert_raise",       vm_assertraise,  fp_no_, .var=nfv_notpush},
+                      {L"self_fun",             vm_selfun,           fp_no_, .var=nfv_notpush},
+                      {L"no_self_fun",            vm_nselfun,          fp_no_, .var=nfv_notpush},
+                      {L"free_mode", vm_freemode,                 fp_no_, .var=nfv_notpush},
+                      {L"normal_mode", vm_nfreemode,              fp_no_, .var=nfv_notpush},
+                      {L"free_opt", vm_free_opt,                  fp_no_, .var=nfv_notpush},
+                      {L"normal_opt", vm_normal_opt,              fp_no_, .var=nfv_notpush},
+                      {L"simple_opt", vm_simple_opt,              fp_no_, .var=nfv_notpush},
                       {NULL, NULL}};
     iterBaseNameFunc(tmp, belong, CFUNC_CORE(var_list));
 }

+ 26 - 26
vmcore/ofunc/src/vobject.c

@@ -451,32 +451,32 @@ ResultType vobject_repo(O_FUNC){
 
 void registeredVObject(R_FUNC){
     LinkValue *object = inter->data.base_obj[B_VOBJECT];
-    NameFunc tmp[] = {{inter->data.mag_func[M_ADD], vobject_add, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_SUB], vobject_sub, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MUL], vobject_mul, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_DIV], vobject_div, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BOOL], vobject_bool, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_REPO], vobject_repo, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_STR], vobject_repo, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_INTDIV], vobject_intdiv, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MOD], vobject_mod, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_POW], vobject_pow, object_free_, .var=nfv_notpush},
-
-                      {inter->data.mag_func[M_EQ], vobject_eq, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_NOTEQ], vobject_noteq, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MOREEQ], vobject_moreeq, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_LESSEQ], vobject_lesseq, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_MORE], vobject_more, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_LESS], vobject_less, object_free_, .var=nfv_notpush},
-
-                      {inter->data.mag_func[M_BAND], vobject_band, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BOR], vobject_bor, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BXOR], vobject_bxor, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BL], vobject_bl, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BR], vobject_br, object_free_, .var=nfv_notpush},
-
-                      {inter->data.mag_func[M_NEGATE], vobject_negate, object_free_, .var=nfv_notpush},
-                      {inter->data.mag_func[M_BNOT], vobject_bnot, object_free_, .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_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_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_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_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},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
     addBaseClassVar(L"vobject", object, belong, inter);

+ 2 - 2
vmcore/parser/__grammar.c

@@ -207,7 +207,7 @@ bool parserParameter(P_FUNC, Parameter **pt, bool enter, bool is_formal, bool is
     Parameter *new_pt = NULL;
     Token *tmp;
     bool last_pt = false;
-    int is_sep = 0;  // 0: 不需要处理 1: 是is_sep 2: 处理过is_sep
+    int is_sep = 0;  // 0: 不需要处理 1: 是is_sep 2: 处理过is_sep (当匹配到;设置is_sep为1)
     enum {
         s_1,  // only_value模式
         s_2,  // name_value模式
@@ -224,7 +224,7 @@ bool parserParameter(P_FUNC, Parameter **pt, bool enter, bool is_formal, bool is
 
     for (int count = 0; !last_pt; count++){  // 计算匹配到parameter的个数
         tmp = NULL;
-        if (is_sep == 1 || !is_formal && count > 1)  // 限制实参的;分隔符前最多只有两个参数
+        if (is_sep == 1 || !is_formal && count > 2)  // 限制实参的;分隔符前最多只有三个参数
             is_sep = 2;
         if (!is_dict && status != s_2 && checkToken(pm, MATHER_MUL))  // is_formal关闭对*args的支持
             status = s_3;

+ 126 - 26
vmcore/src/__run.c

@@ -162,29 +162,29 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
     Argument *tmp = NULL;
     LinkValue *self;
     LinkValue *func;
+    LinkValue *cls;
     enum FunctionPtType pt_type = _func->value->data.function.function_data.pt_type;
     setResultCore(result);
 
+    cls = _func->value->data.function.function_data.cls;  // cls 是绑定的, 无法直接赋值的
+    func = _func;  // func 是绑定的
     switch (pt_sep) {
         case 0:
-            func = _func;
-            self = pt_type == cls_free_ || pt_type == cls_static_ ? _func->value->data.function.function_data.cls : _func->belong;
+            self = _func->belong;
             *base = *arg;
             break;
         case 1: {
             if (*arg != NULL) {
-                if (pt_type == static_) {
+                if (pt_type == fp_cls)
+                    cls = (*arg)->data.value;
+                else if (pt_type == fp_func_)
                     func = (*arg)->data.value;
-                    self = NULL;  // static_模式不需要self
-                }
-                else {
-                    func = _func;
+                else
                     self = (*arg)->data.value;
-                }
                 *arg = (*arg)->next;  // 忽略第一个arg, 但是不释放(在该函数外部统一释放)
                 *base = *arg;
             } else {
-                error_:
+                error2:
                 setResultError(E_ArgumentException, FEW_ARG, line, file, true, CNEXT_NT);
                 return R_error;
             }
@@ -192,13 +192,26 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
         }
         case 2: {
             if (*arg != NULL && (*arg)->next != NULL) {
-                func = (*arg)->data.value;
-                self = (*arg)->next->data.value;  // 第一个参数是func, 第二个是self; 这样做保证了和形参调用的一致
-
+                if (pt_type == fp_cls || pt_type == fp_cls_class || pt_type == fp_cls_obj || pt_type == fp_cls_all)  // 没有func的情况下赋值给cls
+                    cls = (*arg)->data.value;
+                else  // 否则赋值给func
+                    func = (*arg)->data.value;
+                self = (*arg)->next->data.value;
                 *arg = (*arg)->next->next;
                 *base = *arg;
             } else
-                goto error_;
+                goto error2;
+            break;
+        }
+        case 3: {
+            if (*arg != NULL && (*arg)->next != NULL && (*arg)->next->next != NULL) {
+                func = (*arg)->data.value;
+                cls = (*arg)->next->data.value;
+                self = (*arg)->next->next->data.value;
+                *arg = (*arg)->next->next->next;
+                *base = *arg;
+            } else
+                goto error2;
             break;
         }
         default:
@@ -206,18 +219,19 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
             return R_error;
     }
 
-    if (pt_type != free_ && self == NULL) {
-        setResultError(E_ArgumentException, L"function does not belong to anything(not self)", line, file, true, CNEXT_NT);
-        return R_error;
-    }
+    // TODO-szh 检查此处把self设置为NULL后出现错误
+    if (pt_type != fp_cls && pt_type != fp_no_ && pt_type != fp_func_ && pt_type != fp_func_cls && self == NULL)
+        goto error;
+    if ((pt_type == fp_cls || pt_type == fp_func_cls || pt_type == fp_cls_obj || pt_type == fp_cls_class) && cls == NULL)
+        goto error;
 
     switch (pt_type) {
-        case static_:
+        case fp_func_:
             tmp = makeValueArgument(func);
             tmp->next = *arg;
             *arg = tmp;
             break;
-        case class_static_:
+        case fp_func_class:
             tmp = makeValueArgument(func);
             if (self->value->type != V_class) {
                 Inherit *ih = self->value->object.inherit;
@@ -236,14 +250,19 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
                 tmp->next = *arg;
             *arg = tmp;
             break;
-        case cls_static_:
-        case all_static_:
+        case fp_func_cls:
+            tmp = makeValueArgument(func);
+            tmp->next = makeValueArgument(cls);
+            tmp->next->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_func_all:
             tmp = makeValueArgument(func);
             tmp->next = makeValueArgument(self);
             tmp->next->next = *arg;
             *arg = tmp;
             break;
-        case object_static_:
+        case fp_func_obj:
             tmp = makeValueArgument(func);
             if (self->value->type != V_class){
                 tmp->next = makeValueArgument(self);
@@ -253,7 +272,7 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
                 tmp->next = *arg;
             *arg = tmp;
             break;
-        case class_free_:
+        case fp_class:
             if (self->value->type != V_class){
                 Inherit *ih = self->value->object.inherit;
                 self = NULL;
@@ -269,24 +288,105 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
                 *arg = tmp;
             }  // 若无class则不对arg做任何调整
             break;
-        case object_free_:
+        case fp_obj:
             if (self->value->type != V_class) {
                 tmp = makeValueArgument(self);
                 tmp->next = *arg;
                 *arg = tmp;
             }
             break;
-        case cls_free_:
-        case all_free_:
+        case fp_cls:
+            tmp = makeValueArgument(cls);
+            tmp->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_all:
             tmp = makeValueArgument(self);
             tmp->next = *arg;
             *arg = tmp;
             break;
+        case fp_cls_obj:
+            tmp = makeValueArgument(cls);
+            if (self->value->type != V_class) {
+                tmp->next = makeValueArgument(self);
+                tmp->next->next = *arg;
+            } else
+                tmp->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_cls_all:
+            tmp = makeValueArgument(cls);
+            tmp->next = makeValueArgument(self);
+            tmp->next->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_func_cls_all:
+            tmp = makeValueArgument(func);
+            tmp->next = makeValueArgument(cls);
+            tmp->next->next = makeValueArgument(self);
+            tmp->next->next->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_func_cls_obj:
+            tmp = makeValueArgument(func);
+            tmp->next = makeValueArgument(cls);
+            if (self->value->type != V_class) {
+                tmp->next->next = makeValueArgument(self);
+                tmp->next->next->next = *arg;
+            } else
+                tmp->next->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_cls_class:
+            tmp = makeValueArgument(cls);
+
+            if (self->value->type != V_class) {
+                Inherit *ih = self->value->object.inherit;
+                self = NULL;
+                for (PASS; ih != NULL; ih = ih->next)  // 使用循环的方式检查
+                    if (ih->value->value->type == V_class) {
+                        self = ih->value;
+                        break;
+                    }
+            }
+
+            if (self != NULL) {
+                tmp->next = makeValueArgument(self);
+                tmp->next->next = *arg;
+            } else
+                tmp->next = *arg;
+            *arg = tmp;
+            break;
+        case fp_func_cls_class:
+            tmp = makeValueArgument(func);
+            tmp->next = makeValueArgument(cls);
+
+            if (self->value->type != V_class) {
+                Inherit *ih = self->value->object.inherit;
+                self = NULL;
+                for (PASS; ih != NULL; ih = ih->next)  // 使用循环的方式检查
+                    if (ih->value->value->type == V_class) {
+                        self = ih->value;
+                        break;
+                    }
+            }
+
+            if (self != NULL) {
+                tmp->next->next = makeValueArgument(self);
+                tmp->next->next->next = *arg;
+            } else
+                tmp->next->next = *arg;
+            *arg = tmp;
+            break;
         default:
             break;
     }
     setResultBase(result, inter);
     return result->type;
+
+    error:
+    setResultError(E_ArgumentException, L"function does not belong to anything(not self)", line, file, true, CNEXT_NT);
+    return R_error;
 }
 
 void freeFunctionArgument(Argument *arg, Argument *base) {

+ 1 - 1
vmcore/src/inter.c

@@ -121,7 +121,7 @@ void setBaseInterData(struct Inter *inter){
     inter->data.mag_func[M_NOT] = setName("!");
     inter->data.mag_func[M_NEGATE] = setName("-s");
 
-    inter->data.default_pt_type = free_;
+    inter->data.default_pt_type = fp_no_;
     inter->data.var_max = 100;
     inter->data.var_deep = 3;
     inter->data.assert_run = assert_raise;

+ 2 - 2
vmcore/src/runcall.c

@@ -21,7 +21,7 @@ ResultType setClass(FUNC) {
     {
         enum FunctionPtType pt_type_bak = inter->data.default_pt_type;
         VarList *var_backup = tmp->value->object.var->next;
-        inter->data.default_pt_type = object_free_;
+        inter->data.default_pt_type = fp_obj;
         tmp->value->object.var->next = var_list;
 
         // 运行类定义的时候需要调整belong
@@ -67,7 +67,7 @@ ResultType setFunction(FUNC) {
     {
         enum FunctionPtType pt_type_bak = inter->data.default_pt_type;
         VarList *var_backup = func->value->object.var->next;
-        inter->data.default_pt_type = object_free_;
+        inter->data.default_pt_type = fp_obj;
         func->value->object.var->next = var_list;
         // 运行函数初始化模块的时候需要调整belong
         functionSafeInterStatement(CFUNC(st->u.set_function.first_do, func->value->object.var, result, func));

+ 1 - 1
vmcore/src/value.c

@@ -603,7 +603,7 @@ bool needDel(Value *object_value, Inter *inter) {
     if (_del_ == NULL)
         return false;
     type = _del_->value->data.function.function_data.pt_type;
-    if ((type == object_free_ || type == object_static_) && object_value->type == V_class)
+    if ((type == fp_obj || type == fp_func_obj) && object_value->type == V_class)
         return false;
     if (_del_->belong == NULL || _del_->belong->value == object_value || checkAttribution(object_value, _del_->belong->value))
         return true;