Bläddra i källkod

feat: 加入浮点数dou

浮点数支持运算
可以直接使用小数点运算浮点数

link #1
SongZihuan 4 år sedan
förälder
incheckning
0dfc685613

+ 1 - 0
VirtulMathCore/CMakeLists.txt

@@ -19,6 +19,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/signalhandler HANDLER_LIST)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/md5 MD5_LIST)
 
 ADD_LIBRARY(VirtualMathCore STATIC ${SRC_LIST} ${GC_LIST} ${PASER_LIST} ${MEM_LIST} ${FILE_LIST} ${ARGUMENT_LIST} ${OFUNC_LIST} ${HANDLER_LIST} ${CLIB_LIST} ${MD5_LIST})
+TARGET_LINK_LIBRARIES(VirtualMathCore m)
 IF (NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
     TARGET_LINK_LIBRARIES(VirtualMathCore ffi)
     TARGET_LINK_LIBRARIES(VirtualMathCore dl)

+ 2 - 1
VirtulMathCore/include/__macro.h

@@ -31,7 +31,8 @@
 #define MD5_STR_LEN (MD5_SIZE * 2)
 #define MD5_STRING (MD5_STR_LEN + 1)
 
-typedef long long vnum;
+typedef long long vint;
+typedef long double vdou;
 typedef unsigned long long vhashn;
 typedef unsigned long long fline;
 

+ 4 - 2
VirtulMathCore/include/inter.h

@@ -22,7 +22,8 @@ struct Inter{
 
         struct LinkValue *object;
         struct LinkValue *vobject;
-        struct LinkValue *num;
+        struct LinkValue *int_;
+        struct LinkValue *dou;
         struct LinkValue *str;
         struct LinkValue *bool_;
         struct LinkValue *pass_;
@@ -58,7 +59,8 @@ struct Inter{
         struct LinkValue *include_exp;
 
         wchar_t *var_str_prefix;
-        wchar_t *var_num_prefix;
+        wchar_t *var_int_prefix;
+        wchar_t *var_dou_prefix;
         wchar_t *var_bool_prefix;
         wchar_t *var_file_prefix;
         wchar_t *var_none;

+ 1 - 0
VirtulMathCore/include/macro.h

@@ -2,6 +2,7 @@
 #define VIRTUALMATH_MACRO_H
 
 #include <stdio.h>
+#include <math.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>

+ 2 - 1
VirtulMathCore/include/ofunc.h

@@ -5,7 +5,8 @@
 #include "object.h"
 #include "vobject.h"
 #include "sys.h"
-#include "num.h"
+#include "int.h"
+#include "dou.h"
 #include "str.h"
 #include "bool.h"
 #include "pass.h"

+ 3 - 3
VirtulMathCore/include/parameter.h

@@ -84,9 +84,9 @@ ResultType setParameterCore(fline line, char *file, Argument *call, Parameter *f
 ResultType iterParameter(Parameter *call, Argument **base_ad, bool is_dict, FUNC_NT);
 Argument *getArgument(Parameter *call, bool is_dict, FUNC_NT);
 
-ResultType defaultParameter(Parameter **function_ad, vnum *num, FUNC_NT);
-ResultType argumentToVar(Argument **call_ad, vnum *num, FUNC_NT);
-ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, vnum *num, vnum max, bool *status,
+ResultType defaultParameter(Parameter **function_ad, vint *num, FUNC_NT);
+ResultType argumentToVar(Argument **call_ad, vint *num, FUNC_NT);
+ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, vint *num, vint max, bool *status,
                             FUNC_NT);
 ResultType argumentToParameter(Argument **call_ad, Parameter **function_ad, VarList *function_var, FUNC_NT);
 

+ 25 - 18
VirtulMathCore/include/value.h

@@ -39,21 +39,26 @@ enum ValueAuthority {
 
 enum ValueType {
     V_none=0,
-    V_num=1,
-    V_str=2,
-    V_func=3,
-    V_list=4,
-    V_dict=5,
-    V_class=6,
-    V_obj=7,
-    V_bool=8,
-    V_ell=9,
-    V_file=10,
-    V_lib=11,
+    V_int=1,
+    V_dou=2,
+    V_str=3,
+    V_func=4,
+    V_list=5,
+    V_dict=6,
+    V_class=7,
+    V_obj=8,
+    V_bool=9,
+    V_ell=10,
+    V_file=11,
+    V_lib=12,
 };
 
-struct Number {
-    vnum num;
+struct Int {
+    vint num;
+};
+
+struct Dou {
+    vdou num;
 };
 
 struct String {
@@ -94,12 +99,12 @@ struct List {
         L_list,
     } type;
     struct LinkValue **list;
-    vnum size;
+    vint size;
 };
 
 struct Dict {
     struct HashTable *dict;
-    vnum size;
+    vint size;
 };
 
 struct Bool{
@@ -127,7 +132,8 @@ struct Value{
     } object;
 
     union data {
-        struct Number num;
+        struct Int int_;
+        struct Dou dou;
         struct String str;
         struct Function function;
         struct List list;
@@ -167,7 +173,7 @@ struct Result {
     wchar_t *label;
     struct LinkValue *value;
     struct Error *error;
-    vnum times;
+    vint times;
     struct Statement *node;
     bool is_yield;  // 执行的函数是否为生成器
 };
@@ -222,7 +228,8 @@ LinkValue *copyLinkValue(LinkValue *value, Inter *inter);
 Value *useNoneValue(Inter *inter, Result *result);
 Value *makeBoolValue(bool bool_num, fline line, char *file, FUNC_NT);
 Value *makePassValue(fline line, char *file, FUNC_NT);
-Value *makeNumberValue(vnum num, fline line, char *file, FUNC_NT);
+Value *makeIntValue(vint num, fline line, char *file, FUNC_NT);
+Value *makeDouValue(vdou num, fline line, char *file, FUNC_NT);
 Value *makeStringValue(wchar_t *str, fline line, char *file, FUNC_NT);
 Value *makeVMFunctionValue(struct Statement *st, struct Parameter *pt, FUNC_NT);
 Value *makeCFunctionValue(OfficialFunction of, fline line, char *file, FUNC_NT);

+ 6 - 6
VirtulMathCore/include/var.h

@@ -22,7 +22,7 @@ struct HashTable{
 
 struct DefaultVar{
     wchar_t *name;
-    vnum times;
+    vint times;
     struct DefaultVar *next;
 };
 
@@ -55,10 +55,10 @@ VarList *freeVarList(VarList *vl);
 
 vhashn time33(wchar_t *key);
 LinkValue *findVar(wchar_t *name, VarOperation operating, Inter *inter, HashTable *ht);
-LinkValue *findFromVarList(wchar_t *name, vnum times, VarOperation operating, FUNC_CORE);
+LinkValue *findFromVarList(wchar_t *name, vint times, VarOperation operating, FUNC_CORE);
 void addVar(wchar_t *name, LinkValue *value, LinkValue *name_, Inter *inter, HashTable *ht);
 void updateHashTable(HashTable *update, HashTable *new, Inter *inter);
-void addFromVarList(wchar_t *name, LinkValue *name_, vnum times, LinkValue *value, FUNC_CORE);
+void addFromVarList(wchar_t *name, LinkValue *name_, vint times, LinkValue *value, FUNC_CORE);
 
 VarList *pushVarList(VarList *base, Inter *inter);
 VarList *popVarList(VarList *base);
@@ -68,9 +68,9 @@ VarList *connectVarListBack(VarList *base, VarList *back);
 bool comparVarList(VarList *dest, VarList *src);
 VarList *makeObjectVarList(Inherit *value, Inter *inter, VarList *base);
 
-vnum findDefault(DefaultVar *base, wchar_t *name);
-DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vnum times);
+vint findDefault(DefaultVar *base, wchar_t *name);
+DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vint times);
 DefaultVar *freeDefaultVar(DefaultVar *dv);
-DefaultVar *makeDefaultVar(wchar_t *name, vnum times);
+DefaultVar *makeDefaultVar(wchar_t *name, vint times);
 
 #endif //VIRTUALMATH_VAR_H

+ 2 - 2
VirtulMathCore/ofunc/include/__ofunc.h

@@ -14,7 +14,7 @@ void iterBaseNameFunc(NameFunc *list, struct LinkValue *belong, FUNC_CORE);
 void iterBaseClassFunc(NameFunc *list, LinkValue *belong, FUNC_CORE);
 LinkValue *makeBaseChildClass(LinkValue *inherit, Inter *inter);
 
-bool checkIndex(vnum *index, const vnum *size, FUNC_NT);
-bool checkSlice(vnum *first, vnum *second, const vnum *stride, vnum size, FUNC_NT);
+bool checkIndex(vint *index, const vint *size, FUNC_NT);
+bool checkSlice(vint *first, vint *second, const vint *stride, vint size, FUNC_NT);
 void addBaseClassVar(wchar_t *name, LinkValue *obj, LinkValue *belong, Inter *inter);
 #endif //VIRTUALMATH___OFUNC_H

+ 5 - 0
VirtulMathCore/ofunc/include/dou.h

@@ -0,0 +1,5 @@
+#ifndef VIRTUALMATH_DOU_H
+#define VIRTUALMATH_DOU_H
+void registeredDou(R_FUNC);
+void makeBaseDou(Inter *inter);
+#endif //VIRTUALMATH_DOU_H

+ 5 - 0
VirtulMathCore/ofunc/include/int.h

@@ -0,0 +1,5 @@
+#ifndef VIRTUALMATH_INT_H
+#define VIRTUALMATH_INT_H
+void registeredInt(R_FUNC);
+void makeBaseInt(Inter *inter);
+#endif //VIRTUALMATH_INT_H

+ 0 - 5
VirtulMathCore/ofunc/include/num.h

@@ -1,5 +0,0 @@
-#ifndef VIRTUALMATH_NUM_H
-#define VIRTUALMATH_NUM_H
-void registeredNum(R_FUNC);
-void makeBaseNum(Inter *inter);
-#endif //VIRTUALMATH_NUM_H

+ 2 - 2
VirtulMathCore/ofunc/src/__ofunc.c

@@ -81,7 +81,7 @@ LinkValue *makeBaseChildClass(LinkValue *inherit, Inter *inter) {
     return makeLinkValue(new, inter->base_belong, inter);
 }
 
-bool checkIndex(vnum *index, const vnum *size, FUNC_NT){
+bool checkIndex(vint *index, const vint *size, FUNC_NT){
     setResultCore(result);
     if (*index < 0)
         *index = *size + *index;
@@ -95,7 +95,7 @@ bool checkIndex(vnum *index, const vnum *size, FUNC_NT){
     return true;  // true - 保持result为setResultCore的结果
 }
 
-bool checkSlice(vnum *first, vnum *second, const vnum *stride, vnum size, FUNC_NT){
+bool checkSlice(vint *first, vint *second, const vint *stride, vint size, FUNC_NT){
     setResultCore(result);
     *first = *first < 0 ? *first + size : *first;
     *second = *second < 0 ? *second + size : *second;

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

@@ -5,13 +5,13 @@ ResultType bool_new(O_FUNC){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
     int status = 1;
+    setResultCore(result);
     arg = parserValueArgument(ap, arg, &status, NULL);
     if (status != 1){
         setResultError(E_ArgumentException, FEW_ARG, LINEFILE, true, CNEXT_NT);
         return R_error;
     }
 
-    setResultCore(result);
     value = make_new(inter, belong, ap[0].value);
     value->value->type = V_bool;
     value->value->data.bool_.bool_ = false;

+ 21 - 18
VirtulMathCore/ofunc/src/num.c → VirtulMathCore/ofunc/src/dou.c

@@ -1,6 +1,6 @@
 #include "__ofunc.h"
 
-ResultType num_new(O_FUNC){
+ResultType dou_new(O_FUNC){
     LinkValue *value = NULL;
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
@@ -13,13 +13,13 @@ ResultType num_new(O_FUNC){
 
     setResultCore(result);
     value = make_new(inter, belong, ap[0].value);
-    value->value->type = V_num;
-    value->value->data.num.num = 0;
+    value->value->type = V_dou;
+    value->value->data.dou.num = 0.;
     run_init(value, arg, LINEFILE, CNEXT_NT);
     return result->type;
 }
 
-ResultType num_init(O_FUNC){
+ResultType dou_init(O_FUNC){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=name_value, .name=L"num", .must=0, .long_arg=false},
                            {.must=-1}};
@@ -34,18 +34,21 @@ ResultType num_init(O_FUNC){
     if (ap[1].value == NULL)
         goto return_;
     switch (ap[1].value->value->type){
-        case V_num:
-            base->value->data.num.num = ap[1].value->value->data.num.num;
+        case V_int:
+            base->value->data.dou.num = (vdou)ap[1].value->value->data.int_.num;
+            break;
+        case V_dou:
+            base->value->data.dou.num = ap[1].value->value->data.dou.num;
             break;
         case V_str:
-            base->value->data.num.num = wcstoll(ap[1].value->value->data.str.str, NULL, 10);
+            base->value->data.dou.num = wcstold(ap[1].value->value->data.str.str, NULL);
             break;
         case V_bool:
-            base->value->data.num.num = ap[1].value->value->data.bool_.bool_;
+            base->value->data.dou.num = ap[1].value->value->data.bool_.bool_;
             break;
         case V_none:
         case V_ell:
-            base->value->data.num.num = 0;
+            base->value->data.dou.num = 0;
             break;
         default:
             setResultError(E_TypeException, ERROR_INIT(num), LINEFILE, true, CNEXT_NT);
@@ -57,19 +60,19 @@ ResultType num_init(O_FUNC){
     return result->type;
 }
 
-void registeredNum(R_FUNC){
-    LinkValue *object = inter->data.num;
-    NameFunc tmp[] = {{inter->data.object_new, num_new, class_free_},
-                      {inter->data.object_init, num_init, object_free_},
+void registeredDou(R_FUNC){
+    LinkValue *object = inter->data.dou;
+    NameFunc tmp[] = {{inter->data.object_new, dou_new, class_free_},
+                      {inter->data.object_init, dou_init, object_free_},
                       {NULL, NULL}};
     gc_addTmpLink(&object->gc_status);
-    addBaseClassVar(L"num", object, belong, inter);
+    addBaseClassVar(L"dou", object, belong, inter);
     iterBaseClassFunc(tmp, object, CFUNC_CORE(inter->var_list));
     gc_freeTmpLink(&object->gc_status);
 }
 
-void makeBaseNum(Inter *inter){
-    LinkValue *num = makeBaseChildClass(inter->data.vobject, inter);
-    gc_addStatementLink(&num->gc_status);
-    inter->data.num = num;
+void makeBaseDou(Inter *inter){
+    LinkValue *dou = makeBaseChildClass(inter->data.vobject, inter);
+    gc_addStatementLink(&dou->gc_status);
+    inter->data.dou = dou;
 }

+ 5 - 2
VirtulMathCore/ofunc/src/file_.c

@@ -97,12 +97,15 @@ ResultType file_read(O_FUNC){
     if (ap[1].value != NULL) {
         size_t n;
         wint_t ch;
-        if (ap[1].value->value->type != V_num) {
+        if (ap[1].value->value->type != V_int)
+            n = ap[1].value->value->data.int_.num;
+        else if (ap[1].value->value->type != V_dou)
+            n = (vint)ap[1].value->value->data.dou.num;
+        else {
             setResultError(E_TypeException, ONLY_ACC(n, num), LINEFILE, true, CNEXT_NT);
             return R_error;
         }
 
-        n = ap[1].value->value->data.num.num;
         tmp = memWide(n);
         for (int count=0; count < n && (ch = getwc(file->value->data.file.file)) != WEOF; count++)
             tmp[count] = ch;

+ 78 - 0
VirtulMathCore/ofunc/src/int.c

@@ -0,0 +1,78 @@
+#include "__ofunc.h"
+
+ResultType int_new(O_FUNC){
+    LinkValue *value = NULL;
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.must=-1}};
+    int status = 1;
+    arg = parserValueArgument(ap, arg, &status, NULL);
+    if (status != 1){
+        setResultError(E_ArgumentException, FEW_ARG, LINEFILE, true, CNEXT_NT);
+        return R_error;
+    }
+
+    setResultCore(result);
+    value = make_new(inter, belong, ap[0].value);
+    value->value->type = V_int;
+    value->value->data.int_.num = 0;
+    run_init(value, arg, LINEFILE, CNEXT_NT);
+    return result->type;
+}
+
+ResultType int_init(O_FUNC){
+    ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
+                           {.type=name_value, .name=L"num", .must=0, .long_arg=false},
+                           {.must=-1}};
+    LinkValue *base = NULL;
+    setResultCore(result);
+    parserArgumentUnion(ap, arg, CNEXT_NT);
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+
+    base = ap[0].value;
+    if (ap[1].value == NULL)
+        goto return_;
+    switch (ap[1].value->value->type){
+        case V_int:
+            base->value->data.int_.num = ap[1].value->value->data.int_.num;
+            break;
+        case V_dou:
+            base->value->data.int_.num = (vint)ap[1].value->value->data.dou.num;
+            break;
+        case V_str:
+            base->value->data.int_.num = wcstoll(ap[1].value->value->data.str.str, NULL, 10);
+            break;
+        case V_bool:
+            base->value->data.int_.num = ap[1].value->value->data.bool_.bool_;
+            break;
+        case V_none:
+        case V_ell:
+            base->value->data.int_.num = 0;
+            break;
+        default:
+            setResultError(E_TypeException, ERROR_INIT(num), LINEFILE, true, CNEXT_NT);
+            return result->type;
+    }
+
+    return_:
+    setResultBase(result, inter);
+    return result->type;
+}
+
+void registeredInt(R_FUNC){
+    LinkValue *object = inter->data.int_;
+    NameFunc tmp[] = {{inter->data.object_new,  int_new,  class_free_},
+                      {inter->data.object_init, int_init, object_free_},
+                      {NULL, NULL}};
+    gc_addTmpLink(&object->gc_status);
+    addBaseClassVar(L"int", object, belong, inter);
+    iterBaseClassFunc(tmp, object, CFUNC_CORE(inter->var_list));
+    gc_freeTmpLink(&object->gc_status);
+}
+
+void makeBaseInt(Inter *inter){
+    LinkValue *int_ = makeBaseChildClass(inter->data.vobject, inter);
+    gc_addStatementLink(&int_->gc_status);
+    inter->data.int_ = int_;
+}

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

@@ -41,10 +41,10 @@ ResultType list_slice(O_FUNC){
                            {.type=only_value, .must=0, .long_arg=false},
                            {.type=only_value, .must=0, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum first;
-    vnum second;
-    vnum stride;
+    vint size;
+    vint first;
+    vint second;
+    vint stride;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
     if (!CHECK_RESULT(result))
@@ -60,9 +60,9 @@ ResultType list_slice(O_FUNC){
     first = 0;
     second = size;
     stride = 1;
-    for (vnum *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
-        if (ap[i + 1].value != NULL && ap[i + 1].value->value->type == V_num)
-            *(list[i]) = ap[i + 1].value->value->data.num.num;
+    for (vint *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
+        if (ap[i + 1].value != NULL && ap[i + 1].value->value->type == V_int)
+            *(list[i]) = ap[i + 1].value->value->data.int_.num;
         else if (ap[i + 1].value != NULL && ap[i + 1].value->value->type != V_none) {
             setResultError(E_TypeException, ONLY_ACC(first/second/stride, num or null), LINEFILE, true, CNEXT_NT);
             return R_error;
@@ -74,7 +74,7 @@ ResultType list_slice(O_FUNC){
 
     {
         Argument *new_list = NULL;
-        for (vnum i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride) {
+        for (vint i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride) {
             LinkValue *element = ap[0].value->value->data.list.list[i];
             new_list = connectValueArgument(element, new_list);
         }
@@ -91,10 +91,10 @@ ResultType list_slice_assignment(O_FUNC){
                            {.type=only_value, .must=0, .long_arg=false},
                            {.type=only_value, .must=0, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum first;
-    vnum second;
-    vnum stride;
+    vint size;
+    vint first;
+    vint second;
+    vint stride;
     LinkValue *iter_obj = NULL;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
@@ -117,9 +117,9 @@ ResultType list_slice_assignment(O_FUNC){
     first = 0;
     second = size;
     stride = 1;
-    for (vnum *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
-        if (ap[i + 2].value != NULL && ap[i + 2].value->value->type == V_num)
-            *(list[i]) = ap[i + 2].value->value->data.num.num;
+    for (vint *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
+        if (ap[i + 2].value != NULL && ap[i + 2].value->value->type == V_int)
+            *(list[i]) = ap[i + 2].value->value->data.int_.num;
         else if (ap[i + 2].value != NULL && ap[i + 2].value->value->type != V_none) {
             setResultError(E_TypeException, ONLY_ACC(first/second/stride, num or null), LINEFILE, true, CNEXT_NT);
             goto return_;
@@ -130,7 +130,7 @@ ResultType list_slice_assignment(O_FUNC){
         goto return_;
 
     {
-        for (vnum i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride) {
+        for (vint i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride) {
             freeResult(result);
             getIter(iter_obj, 0, LINEFILE, CNEXT_NT);
             if (is_iterStop(result->value, inter)){
@@ -161,10 +161,10 @@ ResultType list_slice_del(O_FUNC){
                            {.type=only_value, .must=0, .long_arg=false},
                            {.type=only_value, .must=0, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum first;
-    vnum second;
-    vnum stride;
+    vint size;
+    vint first;
+    vint second;
+    vint stride;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
     if (!CHECK_RESULT(result))
@@ -180,9 +180,9 @@ ResultType list_slice_del(O_FUNC){
     first = 0;
     second = size;
     stride = 1;
-    for (vnum *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
-        if (ap[i + 1].value != NULL && ap[i + 1].value->value->type == V_num)
-            *(list[i]) = ap[i + 1].value->value->data.num.num;
+    for (vint *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
+        if (ap[i + 1].value != NULL && ap[i + 1].value->value->type == V_int)
+            *(list[i]) = ap[i + 1].value->value->data.int_.num;
         else if (ap[i + 1].value != NULL && ap[i + 1].value->value->type != V_none) {
             setResultError(E_TypeException, ONLY_ACC(first/second/stride, num or null), LINEFILE, true, CNEXT_NT);
             return R_error;
@@ -194,13 +194,13 @@ ResultType list_slice_del(O_FUNC){
 
     {
         LinkValue **new = NULL;
-        vnum new_size = size;
-        for (vnum i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride) {
+        vint new_size = size;
+        for (vint i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride) {
             ap[0].value->value->data.list.list[i] = NULL;
             new_size --;
         }
         new = memCalloc(new_size, sizeof(LinkValue *));
-        for (vnum i = 0, c = 0; i < size; i++) {
+        for (vint i = 0, c = 0; i < size; i++) {
             if (ap[0].value->value->data.list.list[i] != NULL){
                 new[c] = ap[0].value->value->data.list.list[i];
                 c++;
@@ -218,8 +218,8 @@ ResultType list_down_assignment(O_FUNC){
                            {.type=only_value, .must=1, .long_arg=false},
                            {.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum index;
+    vint size;
+    vint index;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
     if (!CHECK_RESULT(result))
@@ -230,13 +230,13 @@ ResultType list_down_assignment(O_FUNC){
         setResultError(E_TypeException, INSTANCE_ERROR(list), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
-    if (ap[2].value->value->type != V_num){
+    if (ap[2].value->value->type != V_int){
         setResultError(E_TypeException, ONLY_ACC(list index, num), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
 
     size = ap[0].value->value->data.list.size;
-    index = ap[2].value->value->data.num.num;
+    index = ap[2].value->value->data.int_.num;
     if (index < 0)
         index = size + index;
     if (index >= size){
@@ -255,8 +255,8 @@ ResultType list_down_del(O_FUNC){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum index;
+    vint size;
+    vint index;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
     if (!CHECK_RESULT(result))
@@ -267,13 +267,13 @@ ResultType list_down_del(O_FUNC){
         setResultError(E_TypeException, INSTANCE_ERROR(list), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
-    if (ap[1].value->value->type != V_num){
-        setResultError(E_TypeException, ONLY_ACC(list index, V_num), LINEFILE, true, CNEXT_NT);
+    if (ap[1].value->value->type != V_int){
+        setResultError(E_TypeException, ONLY_ACC(list index, V_int), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
 
     size = ap[0].value->value->data.list.size;
-    index = ap[1].value->value->data.num.num;
+    index = ap[1].value->value->data.int_.num;
     if (!checkIndex(&index, &size, CNEXT_NT))
         return result->type;
     {
@@ -293,8 +293,8 @@ ResultType list_down(O_FUNC){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum index;
+    vint size;
+    vint index;
     LinkValue *element = NULL;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
@@ -306,13 +306,13 @@ ResultType list_down(O_FUNC){
         setResultError(E_TypeException, INSTANCE_ERROR(list), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
-    if (ap[1].value->value->type != V_num){
-        setResultError(E_TypeException, ONLY_ACC(list index, V_num), LINEFILE, true, CNEXT_NT);
+    if (ap[1].value->value->type != V_int){
+        setResultError(E_TypeException, ONLY_ACC(list index, V_int), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
 
     size = ap[0].value->value->data.list.size;
-    index = ap[1].value->value->data.num.num;
+    index = ap[1].value->value->data.int_.num;
     if (!checkIndex(&index, &size, CNEXT_NT))
         return result->type;
     element = ap[0].value->value->data.list.list[index];

+ 4 - 4
VirtulMathCore/ofunc/src/listiter.c

@@ -15,7 +15,7 @@ ResultType listiter_init(O_FUNC){
         return R_error;
     }
 
-    index = makeLinkValue(makeNumberValue(0, LINEFILE, CNEXT_NT), ap[0].value, inter);
+    index = makeLinkValue(makeIntValue(0, LINEFILE, CNEXT_NT), ap[0].value, inter);
     if (!CHECK_RESULT(result))
         return result->type;
 
@@ -61,8 +61,8 @@ ResultType listiter_next(O_FUNC){
         setResultError(E_TypeException, VALUE_ERROR(listiter.__list, list), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
-    if (index->value->type != V_num){
-        setResultError(E_TypeException, VALUE_ERROR(listiter.__index, V_num), LINEFILE, true, CNEXT_NT);
+    if (index->value->type != V_int){
+        setResultError(E_TypeException, VALUE_ERROR(listiter.__index, V_int), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
 
@@ -77,7 +77,7 @@ ResultType listiter_next(O_FUNC){
     else {
         Result tmp_result;
         setResultCore(&tmp_result);
-        index->value->data.num.num ++;
+        index->value->data.int_.num ++;
         if (addAttributes(L"__index", false, index, LINEFILE, true, CFUNC_NT(var_list, &tmp_result, ap[0].value)))
             freeResult(&tmp_result);
         else {

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

@@ -50,10 +50,10 @@ ResultType str_slice(O_FUNC){
                            {.type=only_value, .must=0, .long_arg=false},
                            {.type=only_value, .must=0, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum first;
-    vnum second;
-    vnum stride;
+    vint size;
+    vint first;
+    vint second;
+    vint stride;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
     if (!CHECK_RESULT(result))
@@ -69,9 +69,9 @@ ResultType str_slice(O_FUNC){
     first = 0;
     second = size;
     stride = 1;
-    for (vnum *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
-        if (ap[i + 1].value != NULL && ap[i + 1].value->value->type == V_num)
-            *(list[i]) = ap[i + 1].value->value->data.num.num;
+    for (vint *list[]={&first, &second, &stride}, i=0; i < 3; i++) {
+        if (ap[i + 1].value != NULL && ap[i + 1].value->value->type == V_int)
+            *(list[i]) = ap[i + 1].value->value->data.int_.num;
         else if (ap[i + 1].value != NULL && ap[i + 1].value->value->type != V_none) {
             setResultError(E_TypeException, VALUE_ERROR(first/second/stride, num or null), LINEFILE, true, CNEXT_NT);
             return R_error;
@@ -83,7 +83,7 @@ ResultType str_slice(O_FUNC){
 
     {
         wchar_t *str = NULL;
-        for (vnum i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride)
+        for (vint i = stride > 0 ? first : second; stride > 0 ? (i < second) : (i > first); i += stride)
             str = memWideCharcpy(str, 1, true, true, ap[0].value->value->data.str.str[i]);
         makeStringValue(str, LINEFILE, CNEXT_NT);
         memFree(str);
@@ -95,8 +95,8 @@ ResultType str_down(O_FUNC){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
-    vnum size;
-    vnum index;
+    vint size;
+    vint index;
     wchar_t element[2];  // TODO-szh 设置为空
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
@@ -108,13 +108,13 @@ ResultType str_down(O_FUNC){
         setResultError(E_TypeException, INSTANCE_ERROR(str), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
-    if (ap[1].value->value->type != V_num){
-        setResultError(E_TypeException, ONLY_ACC(str index, V_num), LINEFILE, true, CNEXT_NT);
+    if (ap[1].value->value->type != V_int){
+        setResultError(E_TypeException, ONLY_ACC(str index, V_int), LINEFILE, true, CNEXT_NT);
         return R_error;
     }
 
     size = memWidelen(ap[0].value->value->data.str.str);
-    index = ap[1].value->value->data.num.num;
+    index = ap[1].value->value->data.int_.num;
     if (!checkIndex(&index, &size, CNEXT_NT))
         return result->type;
     *element = ap[0].value->value->data.str.str[index];
@@ -125,7 +125,7 @@ ResultType str_down(O_FUNC){
 ResultType str_to_list(O_FUNC){
     ArgumentParser ap[] = {{.type=only_value, .must=1, .long_arg=false},
                            {.must=-1}};
-    vnum size;
+    vint size;
     setResultCore(result);
     parserArgumentUnion(ap, arg, CNEXT_NT);
     if (!CHECK_RESULT(result))
@@ -140,7 +140,7 @@ ResultType str_to_list(O_FUNC){
 
     {
         Argument *new_list = NULL;
-        for (vnum i = 0; i < size; i ++) {
+        for (vint i = 0; i < size; i ++) {
             wchar_t str[2] = { NUL };  // TODO-szh 设置为空
             str[0] = ap[0].value->value->data.str.str[i];
             makeStringValue(str, LINEFILE, CNEXT_NT);

+ 61 - 28
VirtulMathCore/ofunc/src/vobject.c

@@ -4,50 +4,72 @@ typedef void (*base_opt)(LinkValue *, Result *, struct Inter *, VarList *var_lis
 
 void vobject_add_base(LinkValue *belong, Result *result, struct Inter *inter, VarList *var_list, Value *left, Value *right) {
     setResultCore(result);
-    if (left->type == V_num && right->type == V_num)
-        makeNumberValue(left->data.num.num + right->data.num.num, LINEFILE, CNEXT_NT);
+    if (left->type == V_int && right->type == V_int)
+        makeIntValue(left->data.int_.num + right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_int && right->type == V_dou)
+        makeDouValue(left->data.int_.num + right->data.dou.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_int)
+        makeDouValue(left->data.dou.num + right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_dou)
+        makeDouValue(left->data.dou.num + right->data.dou.num, LINEFILE, CNEXT_NT);
     else if(left->type == V_str && right->type == V_str){
         wchar_t *new_string = memWidecat(left->data.str.str, right->data.str.str, false, false);
         makeStringValue(new_string, LINEFILE, CNEXT_NT);
         memFree(new_string);
-    }
-    else
+    } else
         setResultError(E_TypeException, CUL_ERROR(Add), LINEFILE, true, CNEXT_NT);
 }
 
 void vobject_sub_base(LinkValue *belong, Result *result, struct Inter *inter, VarList *var_list, Value *left, Value *right) {
     setResultCore(result);
-    if (left->type == V_num && right->type == V_num)
-        makeNumberValue(left->data.num.num - right->data.num.num, LINEFILE, CNEXT_NT);
+    if (left->type == V_int && right->type == V_int)
+        makeIntValue(left->data.int_.num - right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_int && right->type == V_dou)
+        makeDouValue(left->data.int_.num - right->data.dou.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_int)
+        makeDouValue(left->data.dou.num - right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_dou)
+        makeDouValue(left->data.dou.num - right->data.dou.num, LINEFILE, CNEXT_NT);
     else
         setResultError(E_TypeException, CUL_ERROR(Sub), LINEFILE, true, CNEXT_NT);
 }
 
 void vobject_mul_base(LinkValue *belong, Result *result, struct Inter *inter, VarList *var_list, Value *left, Value *right) {
     setResultCore(result);
-    if (left->type == V_num && right->type == V_num)
-        makeNumberValue(left->data.num.num * right->data.num.num, LINEFILE, CNEXT_NT);
-    else if(left->type == V_num && right->type == V_str) {
+    if (left->type == V_int && right->type == V_int)
+        makeIntValue(left->data.int_.num * right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_int && right->type == V_dou)
+        makeDouValue(left->data.int_.num * right->data.dou.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_int)
+        makeDouValue(left->data.dou.num * right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_dou)
+        makeDouValue(left->data.dou.num * right->data.dou.num, LINEFILE, CNEXT_NT);
+    else if(left->type == V_int && right->type == V_str) {
         Value *tmp = left;
         left = right;
         right = tmp;
         goto mul_str;
-    }
-    else if(left->type == V_str && right->type == V_num) mul_str: {
-        wchar_t *new_string = memWidecpySelf(left->data.str.str, right->data.num.num);
+    } else if(left->type == V_str && right->type == V_int) mul_str: {
+        wchar_t *new_string = memWidecpySelf(left->data.str.str, right->data.int_.num);
         makeStringValue(new_string, LINEFILE, CNEXT_NT);
         memFree(new_string);
-    }
-    else
+    } else
         setResultError(E_TypeException, CUL_ERROR(Mul), LINEFILE, true, CNEXT_NT);
 }
 
 void vobject_div_base(LinkValue *belong, Result *result, struct Inter *inter, VarList *var_list, Value *left, Value *right) {
     setResultCore(result);
-    if (left->type == V_num && right->type == V_num) {
-        lldiv_t div_result = lldiv(left->data.num.num, right->data.num.num);
-        makeNumberValue(div_result.quot, LINEFILE, CNEXT_NT);
-    }
+    if (right->type == V_int && right->data.int_.num == 0 || right->type == V_dou && !(right->data.dou.num != 0))  // !(right->data.dou.num != 0) 因为long double检查是否位0时容易出错
+        setResultError(E_TypeException, L"divisor mustn't be 0", LINEFILE, true, CNEXT_NT);
+    else if (left->type == V_int && right->type == V_int) {
+        lldiv_t div_result = lldiv(left->data.int_.num, right->data.int_.num);
+        makeIntValue(div_result.quot, LINEFILE, CNEXT_NT);
+    } else if (left->type == V_dou && right->type == V_int)
+        makeDouValue(left->data.dou.num / (vdou)right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_dou)
+        makeDouValue((vdou)left->data.dou.num / right->data.int_.num, LINEFILE, CNEXT_NT);
+    else if (left->type == V_dou && right->type == V_dou)
+        makeDouValue(left->data.dou.num / right->data.int_.num, LINEFILE, CNEXT_NT);
     else
         setResultError(E_TypeException, CUL_ERROR(Div), LINEFILE, true, CNEXT_NT);
 }
@@ -95,16 +117,18 @@ ResultType vobject_bool(O_FUNC){
     bool result_ = false;
     Value *value = NULL;
     setResultCore(result);
-    {
-        parserArgumentUnion(ap, arg, CNEXT_NT);
-        if (!CHECK_RESULT(result))
-            return result->type;
-        freeResult(result);
-    }
+    parserArgumentUnion(ap, arg, CNEXT_NT);
+    if (!CHECK_RESULT(result))
+        return result->type;
+    freeResult(result);
+
     value = ap[0].value->value;
     switch (value->type) {
-        case V_num:
-            result_ = value->data.num.num != 0;
+        case V_int:
+            result_ = value->data.int_.num != 0;
+            break;
+        case V_dou:
+            result_ = value->data.dou.num != 0;
             break;
         case V_str:
             result_ = memWidelen(value->data.str.str) > 0;
@@ -149,9 +173,18 @@ ResultType vobject_repo(O_FUNC){
     value = ap[0].value->value;
 
     switch (value->type){
-        case V_num: {
+        case V_int: {
             char str[30] = { NUL };
-            snprintf(str, 30, "%lld", value->data.num.num);
+            snprintf(str, 30, "%lld", value->data.int_.num);
+            repo = memStrToWcs(str, false);
+            break;
+        }
+        case V_dou: {
+            char str[30] = { NUL };
+            if (value->data.dou.num != 0)
+                snprintf(str, 30, "%Lf", value->data.dou.num);
+            else
+                str[0] = '0';
             repo = memStrToWcs(str, false);
             break;
         }

+ 18 - 8
VirtulMathCore/src/__run.c

@@ -9,11 +9,11 @@ ResultType getBaseVarInfo(wchar_t **name, int *times, FUNC){
     }
     if (operationSafeInterStatement(CFUNC(st->u.base_var.times, var_list, result, belong)))
         return result->type;
-    if (!isType(result->value->value, V_num)){
+    if (!isType(result->value->value, V_int)){
         setResultErrorSt(E_TypeException, L"Variable operation got unsupported V_num of layers", true, st, CNEXT_NT);
         return result->type;
     }
-    *times = (int)result->value->value->data.num.num;
+    *times = (int)result->value->value->data.int_.num;
     freeResult(result);
 
     not_times:
@@ -30,11 +30,11 @@ ResultType getBaseSVarInfo(wchar_t **name, int *times, FUNC){
     }
     if (operationSafeInterStatement(CFUNC(st->u.base_svar.times, var_list, result, belong)))
         return result->type;
-    if (!isType(result->value->value, V_num)){
+    if (!isType(result->value->value, V_int)){
         setResultErrorSt(E_TypeException, L"Variable operation got unsupported V_num of layers", true, st, CNEXT_NT);
         return result->type;
     }
-    *times = (int)result->value->value->data.num.num;
+    *times = (int)result->value->value->data.int_.num;
 
     freeResult(result);
     not_times:
@@ -65,18 +65,26 @@ wchar_t *setStrVarName(wchar_t *old, bool free_old, Inter *inter) {
     return memWidecat(inter->data.var_str_prefix, old, false, free_old);
 }
 
-wchar_t *setNumVarName(vnum num, struct Inter *inter) {
+wchar_t *setIntVarName(vint num, struct Inter *inter) {
     wchar_t name[50];
     swprintf(name, 50, L"%lld", num);
-    return memWidecat(inter->data.var_num_prefix, name, false, false);
+    return memWidecat(inter->data.var_int_prefix, name, false, false);
+}
+
+wchar_t *setDouVarName(vdou num, struct Inter *inter) {
+    wchar_t name[50];
+    swprintf(name, 50, L"%Lf", num);
+    return memWidecat(inter->data.var_dou_prefix, name, false, false);
 }
 
 wchar_t *getNameFromValue(Value *value, struct Inter *inter) {
     switch (value->type){
         case V_str:
             return setStrVarName(value->data.str.str, false, inter);
-        case V_num:
-            return setNumVarName(value->data.num.num, inter);
+        case V_int:
+            return setIntVarName(value->data.int_.num, inter);
+        case V_dou:
+            return setDouVarName(value->data.dou.num, inter);
         case V_bool:
             if (value->data.bool_.bool_)
                 return memWidecat(inter->data.var_bool_prefix, L"true", false, false);
@@ -440,6 +448,8 @@ bool checkBool(LinkValue *value, fline line, char *file, FUNC_NT){
     LinkValue *_bool_ = findAttributes(inter->data.object_bool, false, LINEFILE, true, CFUNC_NT(var_list, result, value));
     if (!CHECK_RESULT(result))
         return false;
+    freeResult(result);
+
     if (_bool_ != NULL){
         gc_addTmpLink(&_bool_->gc_status);
         callBackCore(_bool_, NULL, line, file, 0, CNEXT_NT);

+ 2 - 1
VirtulMathCore/src/include/__run.h

@@ -3,7 +3,8 @@
 #include "__virtualmath.h"
 
 wchar_t *setStrVarName(wchar_t *old, bool free_old, struct Inter *inter);
-wchar_t *setNumVarName(vnum num, struct Inter *inter);
+wchar_t *setIntVarName(vint num, struct Inter *inter);
+wchar_t *setDouVarName(vdou num, struct Inter *inter);
 wchar_t *getNameFromValue(Value *value, struct Inter *inter);
 ResultType getBaseVarInfo(wchar_t **name, int *times, FUNC);
 ResultType getBaseSVarInfo(wchar_t **name, int *times, FUNC);

+ 6 - 3
VirtulMathCore/src/inter.c

@@ -54,7 +54,8 @@ Inter *makeInter(char *out, char *error_, char *in, LinkValue *belong) {
 
 void setBaseInterData(struct Inter *inter){
     inter->data.var_str_prefix = setName("str_");
-    inter->data.var_num_prefix = setName("num_");
+    inter->data.var_int_prefix = setName("int_");
+    inter->data.var_dou_prefix = setName("double_");
     inter->data.var_file_prefix = setName("file_");
     inter->data.var_none = setName("none");
     inter->data.var_pass = setName("ellipsis");
@@ -93,7 +94,8 @@ void freeBaseInterData(struct Inter *inter){
     gc_freeStatementLink(&inter->base_belong->gc_status);
     gc_freeStatementLink(&inter->data.object->gc_status);
     gc_freeStatementLink(&inter->data.vobject->gc_status);
-    gc_freeStatementLink(&inter->data.num->gc_status);
+    gc_freeStatementLink(&inter->data.int_->gc_status);
+    gc_freeStatementLink(&inter->data.dou->gc_status);
     gc_freeStatementLink(&inter->data.str->gc_status);
     gc_freeStatementLink(&inter->data.bool_->gc_status);
     gc_freeStatementLink(&inter->data.function->gc_status);
@@ -130,7 +132,8 @@ void freeBaseInterData(struct Inter *inter){
     gc_freeStatementLink(&inter->data.import_exc->gc_status);
     gc_freeStatementLink(&inter->data.include_exp->gc_status);
 
-    memFree(inter->data.var_num_prefix);
+    memFree(inter->data.var_int_prefix);
+    memFree(inter->data.var_dou_prefix);
     memFree(inter->data.var_str_prefix);
     memFree(inter->data.var_file_prefix);
     memFree(inter->data.var_object_prefix);

+ 4 - 2
VirtulMathCore/src/ofunc.c

@@ -1,7 +1,8 @@
 #include "__run.h"
 
 static Registered base_func_list[] = {registeredVObject,
-                                      registeredNum,
+                                      registeredInt,
+                                      registeredDou,
                                       registeredStr,
                                       registeredBool,
                                       registeredEllipisis,
@@ -39,7 +40,8 @@ void registeredFunctionName(Inter *inter, LinkValue *belong){
 
     makeBaseVObject(inter);
 
-    makeBaseNum(inter);
+    makeBaseInt(inter);
+    makeBaseDou(inter);
     makeBaseBool(inter);
     makeBaseEllipisis(inter);
     makeBaseFunction(inter);

+ 8 - 8
VirtulMathCore/src/parameter.c

@@ -269,7 +269,7 @@ Argument *dictToArgument(LinkValue *dict_value, long line, char *file, FUNC_NT)
  * @param num
  * @return
  */
-ResultType defaultParameter(Parameter **function_ad, vnum *num, FUNC_NT) {
+ResultType defaultParameter(Parameter **function_ad, vint *num, FUNC_NT) {
     Parameter *function = *function_ad;
     setResultCore(result);
 
@@ -302,7 +302,7 @@ ResultType defaultParameter(Parameter **function_ad, vnum *num, FUNC_NT) {
  * @param num
  * @return
  */
-ResultType argumentToVar(Argument **call_ad, vnum *num, FUNC_NT) {
+ResultType argumentToVar(Argument **call_ad, vint *num, FUNC_NT) {
     Argument *call = *call_ad;
     setResultCore(result);
 
@@ -332,7 +332,7 @@ ResultType argumentToVar(Argument **call_ad, vnum *num, FUNC_NT) {
  * @param num
  * @return
  */
-ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, vnum *num, vnum max, bool *status,
+ResultType parameterFromVar(Parameter **function_ad, VarList *function_var, vint *num, vint max, bool *status,
                             FUNC_NT) {
     Parameter *function = *function_ad;
     bool get = true;
@@ -585,14 +585,14 @@ ResultType setParameterCore(fline line, char *file, Argument *call, Parameter *f
                 break;
             }
             case default_status: {
-                vnum num = 0;
+                vint num = 0;
                 defaultParameter(&function, &num, CFUNC_NT(function_var, result, belong));
                 returnResult(result);
                 break;
             }
             case self_ass: {
-                vnum set_num = 0;
-                vnum get_num = 0;
+                vint set_num = 0;
+                vint get_num = 0;
                 bool dict_status = false;
                 VarList *tmp = makeVarList(inter, true);
 
@@ -778,8 +778,8 @@ Argument *parserValueArgument(ArgumentParser *ap, Argument *arg, int *status, Ar
 
 int parserNameArgument(ArgumentParser ap[], Argument *arg, ArgumentParser **bak, FUNC_NT){
     VarList *tmp = NULL;
-    vnum set_num = 0;
-    vnum get_num = 0;
+    vint set_num = 0;
+    vint get_num = 0;
     int return_;
     setResultCore(result);
 

+ 7 - 7
VirtulMathCore/src/runbranch.c

@@ -1,8 +1,8 @@
 #include "__run.h"
 
 static bool checkNumber(FUNC){
-    if (!isType(result->value->value, V_num)) {
-        setResultErrorSt(E_TypeException, L"Don't get a V_num of layers", true, st, CNEXT_NT);
+    if (!isType(result->value->value, V_int)) {
+        setResultErrorSt(E_TypeException, L"Don't get a int of layers", true, st, CNEXT_NT);
         return false;
     }
     return true;
@@ -931,7 +931,7 @@ ResultType breakCycle(FUNC){
 
     if (!checkNumber(CNEXT))
         return result->type;
-    times_int = (int)result->value->value->data.num.num;
+    times_int = (int)result->value->value->data.int_.num;
     freeResult(result);
 
     not_times:
@@ -953,7 +953,7 @@ ResultType continueCycle(FUNC){
 
     if (!checkNumber(CNEXT))
         return result->type;
-    times_int = (int)result->value->value->data.num.num;
+    times_int = (int)result->value->value->data.int_.num;
     freeResult(result);
 
     not_times:
@@ -975,7 +975,7 @@ ResultType regoIf(FUNC){
 
     if (!checkNumber(CNEXT))
         return result->type;
-    times_int = (int)result->value->value->data.num.num;
+    times_int = (int)result->value->value->data.int_.num;
     freeResult(result);
 
     not_times:
@@ -997,7 +997,7 @@ ResultType restartCode(FUNC){
 
     if (!checkNumber(CNEXT))
         return result->type;
-    times_int = (int)result->value->value->data.num.num;
+    times_int = (int)result->value->value->data.int_.num;
     freeResult(result);
 
     not_times:
@@ -1095,7 +1095,7 @@ ResultType gotoLabel(FUNC){
         memFree(label);
         return result->type;
     }
-    times_int = (int)result->value->value->data.num.num;
+    times_int = (int)result->value->value->data.int_.num;
     freeResult(result);
     not_times:
     if (st->u.goto_.return_ == NULL)

+ 6 - 2
VirtulMathCore/src/runoperation.c

@@ -482,9 +482,13 @@ ResultType getBaseValue(FUNC) {
     }
     else
         switch (st->u.base_value.type) {
-            case number_str:
-                makeNumberValue(wcstoll(st->u.base_value.str, NULL, 10), st->line, st->code_file, CNEXT_NT);
+            case number_str: {
+                if (wcschr(st->u.base_value.str, '.') == NULL)
+                    makeIntValue(wcstoll(st->u.base_value.str, NULL, 10), st->line, st->code_file, CNEXT_NT);
+                else
+                    makeDouValue(wcstold(st->u.base_value.str, NULL), st->line, st->code_file, CNEXT_NT);
                 break;
+            }
             case bool_true:
                 makeBoolValue(true, st->line, st->code_file, CNEXT_NT);
                 break;

+ 23 - 5
VirtulMathCore/src/value.c

@@ -61,14 +61,29 @@ Value *makePassValue(fline line, char *file, FUNC_NT){  // TODO-szh 让切片支
     return tmp;
 }
 
-Value *makeNumberValue(vnum num, fline line, char *file, FUNC_NT) {
+Value *makeIntValue(vint num, fline line, char *file, FUNC_NT) {
     Value *tmp = NULL;
     setResultCore(result);
-    callBackCore(inter->data.num, NULL, line, file, 0, CNEXT_NT);
+    callBackCore(inter->data.int_, NULL, line, file, 0, CNEXT_NT);
     if (!CHECK_RESULT(result))
         return NULL;
     tmp = result->value->value;
-    tmp->data.num.num = num;
+    tmp->data.int_.num = num;
+    return tmp;
+}
+
+Value *makeDouValue(vdou num, fline line, char *file, FUNC_NT) {
+    Value *tmp = NULL;
+    setResultCore(result);
+    if (isnanl(num) || isinfl(num)) {
+        setResultError(E_TypeException, L"decimal exception / [inf/nan]", LINEFILE, true, CNEXT_NT);
+        return NULL;
+    }
+    callBackCore(inter->data.dou, NULL, line, file, 0, CNEXT_NT);
+    if (!CHECK_RESULT(result))
+        return NULL;
+    tmp = result->value->value;
+    tmp->data.dou.num = num;
     return tmp;
 }
 
@@ -660,8 +675,11 @@ bool checkAttribution(Value *self, Value *father){
 
 void printValue(Value *value, FILE *debug, bool print_father, bool print_in) {
     switch (value->type){
-        case V_num:
-            fprintf(debug, "(%lld)", value->data.num.num);
+        case V_int:
+            fprintf(debug, "(%lld)", value->data.int_.num);
+            break;
+        case V_dou:
+            fprintf(debug, "(%Lf)", value->data.dou.num);
             break;
         case V_str:
             fprintf(debug, "'%ls'", value->data.str.str);

+ 9 - 9
VirtulMathCore/src/var.c

@@ -100,7 +100,7 @@ VarList *freeVarList(VarList *vl) {
     return next_var;
 }
 
-DefaultVar *makeDefaultVar(wchar_t *name, vnum times) {
+DefaultVar *makeDefaultVar(wchar_t *name, vint times) {
     DefaultVar *tmp;
     tmp = memCalloc(1, sizeof(DefaultVar));
     tmp->name = memWidecpy(name);
@@ -116,7 +116,7 @@ DefaultVar *freeDefaultVar(DefaultVar *dv) {
     return next;
 }
 
-DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vnum times) {
+DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vint times) {
     for (DefaultVar **tmp = &base; PASS; tmp = &(*tmp)->next){
         if (*tmp == NULL){
             *tmp = makeDefaultVar(name, times);
@@ -130,7 +130,7 @@ DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vnum times) {
     return base;
 }
 
-vnum findDefault(DefaultVar *base, wchar_t *name) {
+vint findDefault(DefaultVar *base, wchar_t *name) {
     for (DefaultVar **tmp = &base; *tmp != NULL; tmp = &(*tmp)->next)
         if (eqWide((*tmp)->name, name))
             return (*tmp)->times;
@@ -199,10 +199,10 @@ LinkValue *findVar(wchar_t *name, VarOperation operating, Inter *inter, HashTabl
  * @param var_list
  * @return
  */
-LinkValue *findFromVarList(wchar_t *name, vnum times, VarOperation operating, FUNC_CORE) {
+LinkValue *findFromVarList(wchar_t *name, vint times, VarOperation operating, FUNC_CORE) {
     LinkValue *tmp = NULL;
-    vnum base = findDefault(var_list->default_var, name) + times;
-    for (vnum i = 0; i < base && var_list->next != NULL; i++)
+    vint base = findDefault(var_list->default_var, name) + times;
+    for (vint i = 0; i < base && var_list->next != NULL; i++)
         var_list = var_list->next;
     if (operating == del_var && var_list != NULL)
         tmp = findVar(name, del_var, inter, var_list->hashtable);
@@ -213,9 +213,9 @@ LinkValue *findFromVarList(wchar_t *name, vnum times, VarOperation operating, FU
     return tmp;
 }
 
-void addFromVarList(wchar_t *name, LinkValue *name_, vnum times, LinkValue *value, FUNC_CORE) {
-    vnum base = findDefault(var_list->default_var, name) + times;
-    for (vnum i = 0; i < base && var_list->next != NULL; i++)
+void addFromVarList(wchar_t *name, LinkValue *name_, vint times, LinkValue *value, FUNC_CORE) {
+    vint base = findDefault(var_list->default_var, name) + times;
+    for (vint i = 0; i < base && var_list->next != NULL; i++)
         var_list = var_list->next;
     addVar(name, value, name_, inter, var_list->hashtable);
 }