Ver Fonte

feat: 调整了获取特殊参数的方法

对class_static和class_free的函数中,获取特殊参数:class时
使用循环检查的方式获取继承链表中的第一个class
SongZihuan há 4 anos atrás
pai
commit
ab6fde166e

+ 0 - 44
VirtulMathCore/parser/__grammar.c

@@ -57,50 +57,6 @@ inline void twoOperation(PASERSSIGNATURE, PasersFunction callBack, GetSymbolFunc
     return_: return;
 }
 
-/**
- * 尾巴一元匹配器
- * tailOperation:
- * | callBack
- * | tailOperation tailFunction
- * @param callBack 符号左、右值匹配函数
- * @param tailFunction 尾巴处理函数
- * @param call_type 左、右值类型
- * @param self_type 输出token的类型
- * @param call_name 左、右值名称(log)
- * @param self_name 输出值名称(log)
- */
-inline void tailOperation(PASERSSIGNATURE, PasersFunction callBack, TailFunction tailFunction, int call_type,
-                          int self_type){
-    while(true){
-        Token *left_token = NULL;
-        struct Statement *st = NULL;
-
-        if (readBackToken(pm) != self_type){
-            
-            if (!callChildStatement(CALLPASERSSIGNATURE, callBack, call_type, &st, NULL))
-                goto return_;
-            addStatementToken(self_type, st, pm);
-            continue;
-        }
-        left_token = popNewToken(pm->tm);
-
-        int tail_status = tailFunction(CALLPASERSSIGNATURE, left_token, &st);
-        if (tail_status == -1){
-            backToken_(pm, left_token);
-            goto return_;
-        }
-        else if(tail_status == 0) {
-            freeToken(left_token, true);
-            goto return_;
-        }
-
-        addStatementToken(self_type, st, pm);
-        freeToken(left_token, false);
-        
-    }
-    return_: return;
-}
-
 /**
  * syntax错误处理器
  * @param pm

+ 0 - 1
VirtulMathCore/parser/include/__grammar.h

@@ -59,7 +59,6 @@ bool parserParameter(PASERSSIGNATURE, Parameter **pt, bool enter, bool is_formal
 
 void twoOperation(PASERSSIGNATURE, PasersFunction callBack, GetSymbolFunction getSymbol, ChecktLeftToken checkleft,
                   int call_type, int self_type, char *call_name, char *self_name, bool is_right);
-void tailOperation(PASERSSIGNATURE, PasersFunction callBack, TailFunction tailFunction, int call_type, int self_type);
 
 void lexEnter(ParserMessage *pm, bool lock);
 

+ 28 - 18
VirtulMathCore/src/__run.c

@@ -189,16 +189,20 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
             break;
         case class_static_:
             tmp = makeValueArgument(func);
-            if (self->value->type == class)
+            if (self->value->type != class) {
+                self = NULL;
+                for (Inherit *ih = self->value->object.inherit; ih != NULL; ih = ih->next)
+                    if (ih->value->value->type == class) {
+                        self = ih->value;
+                        break;
+                    }
+            }
+
+            if (self != NULL) {
                 tmp->next = makeValueArgument(self);
-            else if (self->value->object.inherit != NULL)  // TODO-szh 使用循环检查
-                tmp->next = makeValueArgument(self->value->object.inherit->value);
-            else {
+                tmp->next->next = *arg;
+            } else
                 tmp->next = *arg;
-                *arg = tmp;
-                break;
-            }
-            tmp->next->next = *arg;
             *arg = tmp;
             break;
         case all_static_:
@@ -209,23 +213,29 @@ ResultType setFunctionArgument(Argument **arg, Argument **base, LinkValue *_func
             break;
         case object_static_:
             tmp = makeValueArgument(func);
-            if (self->value->type == class)
-                tmp->next = *arg;
-            else {
+            if (self->value->type != class){
                 tmp->next = makeValueArgument(self);
                 tmp->next->next = *arg;
             }
+            else
+                tmp->next = *arg;
             *arg = tmp;
             break;
         case class_free_:
-            if (self->value->type == class)
+            if (self->value->type != class){
+                self = NULL;
+                for (Inherit *ih = self->value->object.inherit; ih != NULL; ih = ih->next)
+                    if (ih->value->value->type == class) {
+                        self = ih->value;
+                        break;
+                    }
+            }
+
+            if (self != NULL) {
                 tmp = makeValueArgument(self);
-            else if (self->value->object.inherit != NULL)
-                tmp = makeValueArgument(self->value->object.inherit->value);
-            else
-                break;
-            tmp->next = *arg;
-            *arg = tmp;
+                tmp->next = *arg;
+                *arg = tmp;
+            }
             break;
         case object_free_:
             if (self->value->type != class) {