Parcourir la source

find var输出寻找index,并且通过index判断private的访问权限

SongZihuan il y a 5 ans
Parent
commit
6081d6688e
9 fichiers modifiés avec 189 ajouts et 123 suppressions
  1. 1 0
      README.md
  2. 1 0
      gwarf.c
  3. 56 56
      inter/cfunc.c
  4. 103 60
      inter/interpreter.c
  5. 10 1
      inter/interpreter.h
  6. 9 3
      inter/var.c
  7. 1 0
      paser/lexical.c
  8. 6 2
      paser/syntax.c
  9. 2 1
      paser/token.h

+ 1 - 0
README.md

@@ -63,5 +63,6 @@ return x n  函数返回值x,返回n层
 * 设置inline函数,函数执行的时候将不会产生单独的``var_list``,也不会记录``var_list``。
 * 设置对None的point运算均为None
 * 设置了变量访问权限:protect [受到保护的变量] 和public [公开变量]
+* 设置了变量访问权限:private,根据对``var_list``的标签来判断
 ## 关于GWARF
 最后更新时间 : 2020年05月05日 广州

+ 1 - 0
gwarf.c

@@ -34,6 +34,7 @@ int main(){
     setup();
     global_inter = get_inter();  // 拿全局解释器[并声明全局变量]
     var_list *the_var = make_var_base(global_inter->global_var);
+    the_var->tag = run_class;
     statement_base = make_statement_base(global_inter->global_code);
     
     login(the_var);

+ 56 - 56
inter/cfunc.c

@@ -55,37 +55,37 @@ GWARF_value to_object(GWARF_value value, var_list *the_var){  // 把GWARF_value
     func_result.value.value.int_value = 0;
     var *tmp;
     if(value.type == NUMBER_value){
-        tmp = find_var(the_var, 0, "double");
+        tmp = find_var(the_var, 0, "double", NULL);
         if(tmp != NULL){
             func_result.value = tmp->value;
         }
     }
     else if(value.type == INT_value){
-        tmp = find_var(the_var, 0, "int");
+        tmp = find_var(the_var, 0, "int", NULL);
         if(tmp != NULL){
             func_result.value = tmp->value;
         }
     }
     else if(value.type == BOOL_value){
-        tmp = find_var(the_var, 0, "bool");
+        tmp = find_var(the_var, 0, "bool", NULL);
         if(tmp != NULL){
             func_result.value = tmp->value;
         }
     }
     else if(value.type == STRING_value){
-        tmp = find_var(the_var, 0, "str");
+        tmp = find_var(the_var, 0, "str", NULL);
         if(tmp != NULL){
             func_result.value = tmp->value;
         }
     }
     else if(value.type == LIST_value){
-        tmp = find_var(the_var, 0, "list");
+        tmp = find_var(the_var, 0, "list", NULL);
         if(tmp != NULL){
             func_result.value = tmp->value;
         }
     }
     else if(value.type == DICT_value){
-        tmp = find_var(the_var, 0, "dict");
+        tmp = find_var(the_var, 0, "dict", NULL);
         if(tmp != NULL){
             func_result.value = tmp->value;
         }
@@ -101,7 +101,7 @@ GWARF_value to_tuple(GWARF_value value, var_list *the_var){  // 把GWARF_value
     GWARF_result func_result = GWARF_result_reset;
     func_result.u = statement_end;
     var *tmp;
-    tmp = find_var(the_var, 0, "tuple");
+    tmp = find_var(the_var, 0, "tuple", NULL);
     if(tmp != NULL){
         func_result.value = tmp->value;
     }
@@ -117,7 +117,7 @@ GWARF_result get_object(parameter *tmp_s, char *name, var_list *the_var){  // 
     func_result.u = statement_end;
     func_result.value.type = NULL_value;
     func_result.value.value.int_value = 0;
-    var *tmp = find_var(the_var, 0, name);
+    var *tmp = find_var(the_var, 0, name, NULL);
     if(tmp != NULL){
         func_result.value = tmp->value;
     }
@@ -140,7 +140,7 @@ GWARF_result to_error(char *error_info, char *error_type, var_list *the_var){  /
     return_result.u = error;
     return_result.error_info = error_info;
 
-    var *tmp = find_var(the_var, 0, error_type);
+    var *tmp = find_var(the_var, 0, error_type, NULL);
 
     if(tmp != NULL){
         func_result.value = tmp->value;
@@ -494,7 +494,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             break;
         }
         case __value__func:{  // 若想实现运算必须要有这个方法
-            var *tmp = find_var(login_var, 0, "value");  // gobject类的value存储在self.value中
+            var *tmp = find_var(login_var, 0, "value", NULL);  // gobject类的value存储在self.value中
             if(tmp != NULL){
                 return_value.value = tmp->value;  // 取得用于计算的数值
             }
@@ -516,7 +516,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -539,7 +539,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -562,7 +562,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -585,7 +585,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -608,7 +608,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -631,7 +631,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -654,7 +654,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -677,7 +677,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -700,7 +700,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -723,7 +723,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -746,7 +746,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -769,7 +769,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -792,7 +792,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -815,7 +815,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -838,7 +838,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -861,7 +861,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -884,7 +884,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -907,7 +907,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -920,7 +920,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
         }
         case __negative__func:{
             GWARF_result left_tmp = GWARF_result_reset;
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -943,7 +943,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -966,7 +966,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -989,7 +989,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1012,7 +1012,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1037,7 +1037,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1060,7 +1060,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1083,7 +1083,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1106,7 +1106,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1129,7 +1129,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1152,7 +1152,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1175,7 +1175,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             }
             GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
             reight_tmp = get__value__(&base_the_var, the_var);
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1188,7 +1188,7 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
         }
         case __bitnot__func:{
             GWARF_result left_tmp = GWARF_result_reset;
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 left_tmp.value = tmp->value;
             }
@@ -1268,7 +1268,7 @@ GWARF_result int_official_func(func *the_func, parameter *tmp_s, var_list *the_v
 
                 // 执行__init__
                 GWARF_result self_value = GWARF_result_reset;
-                var *tmp = find_var(login_var, 0, "value");
+                var *tmp = find_var(login_var, 0, "value", NULL);
                 if(tmp != NULL){
                     self_value.value = to_int(tmp->value, out_var);
                 }
@@ -1385,7 +1385,7 @@ GWARF_result double_official_func(func *the_func, parameter *tmp_s, var_list *th
 
                 // 执行__init__
                 GWARF_result self_value = GWARF_result_reset;
-                var *tmp = find_var(login_var, 0, "value");
+                var *tmp = find_var(login_var, 0, "value", NULL);
                 if(tmp != NULL){
                     self_value.value = to_int(tmp->value, out_var);
                 }
@@ -1721,7 +1721,7 @@ GWARF_result bool_official_func(func *the_func, parameter *tmp_s, var_list *the_
 
                 // 执行__init__
                 GWARF_result self_value = GWARF_result_reset;
-                var *tmp = find_var(login_var, 0, "value");
+                var *tmp = find_var(login_var, 0, "value", NULL);
                 if(tmp != NULL){
                     self_value.value = to_bool_(tmp->value, out_var);
                 }
@@ -1844,7 +1844,7 @@ GWARF_result tuple_official_func(func *the_func, parameter *tmp_s, var_list *the
             break;
         }
         case __len__func:{  // return index
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             return_value.value.type = INT_value;
             return_value.value.value.int_value = tmp->value.value.list_value->index;
             break;
@@ -1859,7 +1859,7 @@ GWARF_result tuple_official_func(func *the_func, parameter *tmp_s, var_list *the
             break;
         }
         case __next__func:{  // return index
-            var *tmp = find_var(login_var, 0, "iter_value");
+            var *tmp = find_var(login_var, 0, "iter_value", NULL);
             int iter_index, len;
             if(tmp == NULL){
                 iter_index = 0;
@@ -1868,7 +1868,7 @@ GWARF_result tuple_official_func(func *the_func, parameter *tmp_s, var_list *the
                 iter_index = to_int(tmp->value, out_var).value.int_value;
             }
 
-            tmp = find_var(login_var, 0, "value");
+            tmp = find_var(login_var, 0, "value", NULL);
             len = tmp->value.value.list_value->index;
             printf("len = %d, iter_index = %d\n", len, iter_index);
             if(iter_index >= len){  // 已经超出
@@ -1885,7 +1885,7 @@ GWARF_result tuple_official_func(func *the_func, parameter *tmp_s, var_list *the
             break;
         }
         case __down__func:{  // return index
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(is_error(&tmp_result)){  // Name Error错误
@@ -1909,7 +1909,7 @@ GWARF_result tuple_official_func(func *the_func, parameter *tmp_s, var_list *the
             break_down: break;
         }
         case __slice__func:{  // return index
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             int len = tmp->value.value.list_value->index;
             int start, end;
             if(tmp != NULL){
@@ -1999,7 +1999,7 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
     switch (the_func->official_func)
     {
         case __set__func:{  // return index
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(is_error(&tmp_result)){  // Name Error错误
@@ -2161,7 +2161,7 @@ GWARF_value parameter_to_dict(parameter *tmp_s, var_list *the_var){  // 把param
                 GWARF_result get = GWARF_result_reset;  // 不会和下面发生重复计算
                 var_list *call_var = tmp.value.value.object_value->the_var;
 
-                var *__down__tmp = find_var(call_var, 0, "__down__");
+                var *__down__tmp = find_var(call_var, 0, "__down__", NULL);
                 if(__down__tmp != NULL){
                     get.value = __down__tmp->value;
                     get.father = &(tmp.value);  // 设置father
@@ -2306,7 +2306,7 @@ GWARF_result dict_official_func(func *the_func, parameter *tmp_s, var_list *the_
             break;
         }
         case __next__func:{  // return index
-            var *tmp = find_var(login_var, 0, "iter_value");
+            var *tmp = find_var(login_var, 0, "iter_value", NULL);
             int iter_index, len;
             if(tmp == NULL){
                 iter_index = 0;
@@ -2315,7 +2315,7 @@ GWARF_result dict_official_func(func *the_func, parameter *tmp_s, var_list *the_
                 iter_index = to_int(tmp->value, out_var).value.int_value;
             }
 
-            tmp = find_var(login_var, 0, "value");
+            tmp = find_var(login_var, 0, "value", NULL);
             len = tmp->value.value.dict_value->index;
             if(iter_index >= len){
                 return_value = to_error("Max Iter", "IterException", the_var);
@@ -2340,7 +2340,7 @@ GWARF_result dict_official_func(func *the_func, parameter *tmp_s, var_list *the_
             next_break: break;
         }
         case __down__func:{  // return index
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(is_error(&tmp_result)){  // Name Error错误
@@ -2367,7 +2367,7 @@ GWARF_result dict_official_func(func *the_func, parameter *tmp_s, var_list *the_
             break_down: break;
         }
         case __set__func:{  // return index
-            var *tmp = find_var(login_var, 0, "value");
+            var *tmp = find_var(login_var, 0, "value", NULL);
             if(tmp != NULL){
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(is_error(&tmp_result)){  // Name Error错误
@@ -2481,7 +2481,7 @@ GWARF_result run_func_core(GWARF_value *base_the_var, var_list *the_var, char *n
             reight_tmp.return_times = times;
             goto return_result;  // 如果类型不是object或者class
         }
-        var *tmp_var = find_var(call_var, 0, name);
+        var *tmp_var = find_var(call_var, 0, name, NULL);
         if(tmp_var != NULL){
             get.value = tmp_var->value;  // TODO:: 需要检查__value__是否存在
             get.father = base_the_var;  // 设置father

+ 103 - 60
inter/interpreter.c

@@ -203,7 +203,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             GWARF_value base_the_var = tmp_result.value;
 
             if(base_the_var.type == CLASS_value){  // is class so that can use "."
-                var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__slice__");
+                var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__slice__", NULL);
                 if(tmp != NULL){
                     get.value = tmp->value;
                     get.father = &base_the_var;  // 设置father
@@ -212,7 +212,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
                 }
             }
             else if(base_the_var.type == OBJECT_value){
-                var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__slice__");
+                var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__slice__", NULL);
                 if(tmp != NULL){
                     get.value = tmp->value;
                     get.father = &base_the_var;  // 设置father
@@ -253,12 +253,46 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
                     }
                 }
             }
-            var *tmp = find_var(the_var, from, (the_statement->code).base_var.var_name);
+            int index = 0;
+            int max_object = -1;  // 记录class的最大位置
+            int max_class = -1;  // 记录class的最大位置
+            int max = 0;
+            var_list *start = the_var;
+            while (1)
+            {
+                if(start == NULL){  // don't get the var and not next
+                    if(max_class == -1) max_class = max;
+                    if(max_object == -1) max_object = max;
+                    break;
+                }
+                else if(start->tag == run_class && max_class == -1){  // don't get the var but can next
+                    max_class = max;
+                    break;
+                }
+                else if(start->tag == run_object && max_object == -1){  // don't get the var but can next
+                    max_object = max;
+                }
+                if(max_object != -1 && max_class != -1){
+                    break;
+                }
+                start = start->next;
+                max += 1;
+            }
+
+            var *tmp = find_var(the_var, from, (the_statement->code).base_var.var_name, &index);
             // 检查权限
-            if(tmp == NULL || (tmp->lock == protect && (the_statement->code).base_var.lock_token == public_token)){
-                char *tmp = malloc((size_t)( 21 + strlen(the_statement->code.base_var.var_name) ));
-                sprintf(tmp, "name not found [%s]\n", the_statement->code.base_var.var_name);
-                return_value = to_error(tmp, "NameException", the_var);
+            char *str_tmp;  // 因为goto语句,所以声明放到外面
+            if(tmp == NULL){
+                var_error:
+                str_tmp = malloc((size_t)( 21 + strlen(the_statement->code.base_var.var_name) ));
+                sprintf(str_tmp, "name not found [%s]\n", the_statement->code.base_var.var_name);
+                return_value = to_error(str_tmp, "NameException", the_var);
+            }
+            else if(tmp->lock == protect && the_statement->code.base_var.lock_token == public_token){  // 权限不够
+                goto var_error;
+            }
+            else if(tmp->lock == private && ((the_statement->code.base_var.lock_token == protect && index > max_object && index > max_class) || the_statement->code.base_var.lock_token == public_token)){
+                goto var_error;
             }
             else
             {
@@ -302,7 +336,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             char *str = to_str_dict(eq_object.value, the_var).value.string;
             printf("str = %s\n", str);
 
-            var *tmp = find_var(the_var, from, str);
+            var *tmp = find_var(the_var, from, str, NULL);
             if(tmp == NULL){  // 输出name error[共两处会输出]
                 char *tmp = malloc((size_t)( 21 + strlen(str) ));
                 sprintf(tmp, "name not found [%s]\n", str);
@@ -383,7 +417,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
 
             GWARF_value base_the_var = tmp_result.value;
             if(base_the_var.type == CLASS_value){  // is class so that can use "."
-                var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__down__");
+                var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__down__", NULL);
                 if(tmp != NULL){
                     get.value = tmp->value;
                     get.father = &base_the_var;  // 设置father
@@ -392,7 +426,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
                 }
             }
             else if(base_the_var.type == OBJECT_value){
-                var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__down__");
+                var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__down__", NULL);
                 if(tmp != NULL){
                     get.value = tmp->value;
                     get.father = &base_the_var;  // 设置father
@@ -411,6 +445,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             func_tmp->done = the_statement->code.def.done;
             func_tmp->parameter_list = the_statement->code.def.parameter_list;
             func_tmp->self = make_var_base(make_hash_var());
+            func_tmp->self->tag = run_object;
             if(the_statement->code.def.is_inline){  // inline函数
                 func_tmp->the_var = NULL;
                 goto make_func;  // 跳过其他设置
@@ -454,7 +489,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             func_tmp->done = the_statement->code.lambda_func.done;
             func_tmp->parameter_list = the_statement->code.lambda_func.parameter_list;
             func_tmp->the_var = copy_var_list(the_var);
-            func_tmp->self = make_var_base(make_hash_var());
+            func_tmp->self = make_var_base(make_hash_var());  // 默认设置为run_func
             func_tmp->type = customize;  // func by user
             func_tmp->is_class = auto_func;
             func_tmp->is_lambda = true;
@@ -470,6 +505,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             class_object *class_tmp = malloc(sizeof(class_object));
 
             class_tmp->the_var = make_var_base(make_hash_var());  // make class var list
+            class_tmp->the_var->tag = run_class;
             class_value.value.value.class_value = class_tmp;
 
             // 获取father  -- append_by_var_list[拼凑]
@@ -500,7 +536,7 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
                 }
             }
             else{
-                var *object_tmp = find_var(the_var, 0, "object");
+                var *object_tmp = find_var(the_var, 0, "object", NULL);
                 if(object_tmp != NULL){
                     father_tmp.value = object_tmp->value;
                     append_by_var_list(class_tmp->the_var, father_tmp.value.value.class_value->the_var);
@@ -848,7 +884,7 @@ GWARF_result get_value(statement *the_statement, var_list *the_var, var_list *ou
     {
         case base_var:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
             int from = 0;
-            var *tmp = find_var(the_var, from, (the_statement->code).base_var.var_name);
+            var *tmp = find_var(the_var, from, (the_statement->code).base_var.var_name, NULL);
             if(tmp == NULL){  // 输出name error[共两处会输出]
                 char *tmp = malloc((size_t)( 21 + strlen(the_statement->code.base_var.var_name) ));
                 sprintf(tmp, "name not found [%s]\n", the_statement->code.base_var.var_name);
@@ -871,7 +907,7 @@ GWARF_result get_value(statement *the_statement, var_list *the_var, var_list *ou
             char *str = to_str_dict(eq_object.value, out_var).value.string;
             printf("str = %s\n", str);
 
-            var *tmp = find_var(the_var, from, str);
+            var *tmp = find_var(the_var, from, str, NULL);
             if(tmp == NULL){  // 输出name error[共两处会输出]
                 char *tmp = malloc((size_t)( 21 + strlen(str) ));
                 sprintf(tmp, "name not found [%s]\n", str);
@@ -932,6 +968,7 @@ GWARF_result import_func(statement *the_statement, var_list *the_var){
 
     global_inter = get_inter();  // 拿全局解释器[并声明全局变量]
     var_list *new_the_var = make_var_base(global_inter->global_var);
+    new_the_var->tag = run_class;
     statement_base = make_statement_base(global_inter->global_code);
     
     login(new_the_var);
@@ -1135,6 +1172,7 @@ GWARF_result for_func(statement *the_statement, var_list *the_var){  // read the
     GWARF_result value = GWARF_result_reset;
     hash_var *tmp = make_hash_var();  // base_var
     the_var = append_var_list(tmp, the_var);
+    the_var->tag = run_while;
     bool condition;
     if(the_statement->code.for_cycle.first != NULL){
         GWARF_result tmp_result = traverse(the_statement->code.for_cycle.first, the_var, false); // first to do
@@ -1323,7 +1361,7 @@ GWARF_result try_func(statement *the_statement, var_list *the_var){  // read the
     GWARF_result value = GWARF_result_reset;
 
     hash_var *tmp = make_hash_var();  // base_var
-    the_var = append_var_list(tmp, the_var);
+    the_var = append_var_list(tmp, the_var);  // run func
 
     again: 
     puts("----try----");
@@ -1451,7 +1489,7 @@ GWARF_result forin_func(statement *the_statement, var_list *the_var){  // read t
     GWARF_result value = GWARF_result_reset;
     hash_var *tmp = make_hash_var();  // base_var
     the_var = append_var_list(tmp, the_var);
-    
+    the_var->tag = run_while;
     GWARF_result tmp_result = traverse(the_statement->code.for_in_cycle.iter, the_var, false);  // 取得迭代器
     if(is_error(&tmp_result)){  // Name Error错误
         // puts("STOP:: Name No Found!");
@@ -1540,7 +1578,7 @@ GWARF_result while_func(statement *the_statement, var_list *the_var){  // read t
 
     hash_var *tmp = make_hash_var();  // base_var
     the_var = append_var_list(tmp, the_var);
-
+    the_var->tag = run_while;
     bool condition;
     while (1){
         if(!do_while){  // do_while 为 true的时候跳过条件检查
@@ -1839,6 +1877,9 @@ GWARF_result assignment_statement_core(statement *the_statement, var_list *the_v
                 case protect_token:
                 the_lock = protect;
                 break;
+                case private_token:
+                the_lock = private;
+                break;
             }
         }
         value = assignment_func(left, right_result, login_var, from, the_lock);
@@ -1890,7 +1931,7 @@ GWARF_result assignment_statement_core(statement *the_statement, var_list *the_v
         }
         GWARF_value base_the_var = tmp_result.value;  // 不用取value
         if(base_the_var.type == CLASS_value){  // is class so that can use "."
-            var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__set__");
+            var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__set__", NULL);
             if(tmp != NULL){
                 get.value = tmp->value;
                 get.father = &base_the_var;  // 设置father
@@ -1901,7 +1942,7 @@ GWARF_result assignment_statement_core(statement *the_statement, var_list *the_v
             }
         }
         else if(base_the_var.type == OBJECT_value){
-            var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__set__");
+            var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__set__", NULL);
             if(tmp != NULL){
                 get.value = tmp->value;
                 get.father = &base_the_var;  // 设置father
@@ -1997,7 +2038,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
     return_result.value.value.int_value = 0;
 
     int assignment_type = 0;  // 0-根据tmp_x进行赋值,1-根据tmp_s赋值,2-赋值到kwargs
-    var_list *tmp_var = make_var_base(make_hash_var());  // 为1-模式准备
+    var_list *tmp_var = make_var_base(make_hash_var());  // 为1-模式准备[默认为run_func]
 
     while(1){
         if ((tmp_x == NULL)&&(tmp_s == NULL)){  // the last
@@ -2026,7 +2067,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                         GWARF_result func_result = GWARF_result_reset;
                         var *list_init;
                         func_result.u = statement_end;
-                        list_init = find_var(old_var_list, 0, "list");
+                        list_init = find_var(old_var_list, 0, "list", NULL);
                         if(list_init != NULL){
                             func_result.value = list_init->value;
                         }
@@ -2074,7 +2115,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                                 GWARF_result get = GWARF_result_reset;
                                 var_list *call_var = dict_tmp.value.object_value->the_var;
 
-                                var *__down__tmp = find_var(call_var, 0, "__set__");
+                                var *__down__tmp = find_var(call_var, 0, "__set__", NULL);
                                 if(__down__tmp != NULL){
                                     get.value = __down__tmp->value;
                                     get.father = &(dict_tmp);  // 设置father
@@ -2138,7 +2179,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                 GWARF_result get = GWARF_result_reset;
                 var_list *call_var = tmp.value.value.object_value->the_var;
 
-                var *__down__tmp = find_var(call_var, 0, "__down__");
+                var *__down__tmp = find_var(call_var, 0, "__down__", NULL);
                 if(__down__tmp != NULL){
                     get.value = __down__tmp->value;
                     get.father = &(tmp.value);  // 设置father
@@ -2235,7 +2276,7 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
 
         if(new_var_list){
             hash_var *tmp = make_hash_var();  // base_var
-            the_var = append_var_list(tmp, the_var);
+            the_var = append_var_list(tmp, the_var);  // run func
         }
 
         if(func_->type == customize){  // 用户定义的方法
@@ -2303,13 +2344,15 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
     else if(get.value.type == CLASS_value){  // 生成实例
         the_object *object_tmp = malloc(sizeof(the_object));  // 生成object的空间
         object_tmp->cls = get.value.value.class_value->the_var;
-        object_tmp->the_var = append_by_var_list(make_var_base(make_hash_var()), object_tmp->cls);
+        var_list *tmp_var_list = make_var_base(make_hash_var());
+        object_tmp->the_var = append_by_var_list(tmp_var_list, object_tmp->cls);
+        object_tmp->the_var->tag = run_object;
         GWARF_value tmp = GWARF_value_reset;
         tmp.type = OBJECT_value;
         tmp.value.object_value = object_tmp;
 
         // 执行__init__
-        var *init_tmp = find_var(object_tmp->cls, 0, "__init__");
+        var *init_tmp = find_var(object_tmp->cls, 0, "__init__", NULL);
         if(init_tmp != NULL){  // 找到了__init__
             func *func_ = init_tmp->value.value.func_value;
             parameter *tmp_x = func_->parameter_list;
@@ -2317,7 +2360,7 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
             // tmp_x:形参,tmp_s:实参
 
             hash_var *tmp = make_hash_var();  // base_var
-            the_var = append_var_list(tmp, the_var);
+            the_var = append_var_list(tmp, the_var);  // 默认设置为run func
 
             if(func_->type == customize){  // 用户定义的方法
                 GWARF_result father = GWARF_result_reset;
@@ -2378,7 +2421,7 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
     }
     else if(get.value.type == OBJECT_value){  // 调用__call__方法
         // 执行__init__
-        var *call_tmp = find_var(get.value.value.object_value->the_var, 0, "__call__");
+        var *call_tmp = find_var(get.value.value.object_value->the_var, 0, "__call__", NULL);
         if(call_tmp != NULL){  // 找到了__init__
             func *func_ = call_tmp->value.value.func_value;
             parameter *tmp_x = func_->parameter_list;
@@ -2530,7 +2573,7 @@ GWARF_result bit_and_func(GWARF_result left_result, GWARF_result right_result, v
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitand__");
+        var *tmp = find_var(call_var, 0, "__bitand__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2544,7 +2587,7 @@ GWARF_result bit_and_func(GWARF_result left_result, GWARF_result right_result, v
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitand__");
+        var *tmp = find_var(call_var, 0, "__bitand__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2600,7 +2643,7 @@ GWARF_result bit_or_func(GWARF_result left_result, GWARF_result right_result, va
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitor__");
+        var *tmp = find_var(call_var, 0, "__bitor__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2614,7 +2657,7 @@ GWARF_result bit_or_func(GWARF_result left_result, GWARF_result right_result, va
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitor__");
+        var *tmp = find_var(call_var, 0, "__bitor__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2671,7 +2714,7 @@ GWARF_result bit_notor_func(GWARF_result left_result, GWARF_result right_result,
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitnotor__");
+        var *tmp = find_var(call_var, 0, "__bitnotor__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2685,7 +2728,7 @@ GWARF_result bit_notor_func(GWARF_result left_result, GWARF_result right_result,
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitnotor__");
+        var *tmp = find_var(call_var, 0, "__bitnotor__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2741,7 +2784,7 @@ GWARF_result bit_left_func(GWARF_result left_result, GWARF_result right_result,
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitleft__");
+        var *tmp = find_var(call_var, 0, "__bitleft__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2755,7 +2798,7 @@ GWARF_result bit_left_func(GWARF_result left_result, GWARF_result right_result,
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitleftr__");
+        var *tmp = find_var(call_var, 0, "__bitleftr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2811,7 +2854,7 @@ GWARF_result bit_right_func(GWARF_result left_result, GWARF_result right_result,
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitright__");
+        var *tmp = find_var(call_var, 0, "__bitright__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2825,7 +2868,7 @@ GWARF_result bit_right_func(GWARF_result left_result, GWARF_result right_result,
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitrightr__");
+        var *tmp = find_var(call_var, 0, "__bitrightr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2881,7 +2924,7 @@ GWARF_result bit_not_func(GWARF_result right_result, var_list *the_var){  // the
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__bitnot__");
+        var *tmp = find_var(call_var, 0, "__bitnot__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2932,7 +2975,7 @@ GWARF_result add_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__add__");
+        var *tmp = find_var(call_var, 0, "__add__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -2946,7 +2989,7 @@ GWARF_result add_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__add__");
+        var *tmp = find_var(call_var, 0, "__add__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3011,7 +3054,7 @@ GWARF_result sub_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__sub__");
+        var *tmp = find_var(call_var, 0, "__sub__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3024,7 +3067,7 @@ GWARF_result sub_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__subr__");
+        var *tmp = find_var(call_var, 0, "__subr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3077,7 +3120,7 @@ GWARF_result negative_func(GWARF_result right_result, var_list *the_var){  // th
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__negative__");
+        var *tmp = find_var(call_var, 0, "__negative__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3139,7 +3182,7 @@ GWARF_result mul_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__mul__");
+        var *tmp = find_var(call_var, 0, "__mul__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3152,7 +3195,7 @@ GWARF_result mul_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__mul__");
+        var *tmp = find_var(call_var, 0, "__mul__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3264,7 +3307,7 @@ GWARF_result div_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__div__");
+        var *tmp = find_var(call_var, 0, "__div__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3277,7 +3320,7 @@ GWARF_result div_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__divr__");
+        var *tmp = find_var(call_var, 0, "__divr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3331,7 +3374,7 @@ GWARF_result mod_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__mod__");
+        var *tmp = find_var(call_var, 0, "__mod__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3344,7 +3387,7 @@ GWARF_result mod_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__modr__");
+        var *tmp = find_var(call_var, 0, "__modr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3398,7 +3441,7 @@ GWARF_result int_div_func(GWARF_result left_result, GWARF_result right_result, v
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__idiv__");
+        var *tmp = find_var(call_var, 0, "__idiv__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3411,7 +3454,7 @@ GWARF_result int_div_func(GWARF_result left_result, GWARF_result right_result, v
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__idivr__");  // 整除
+        var *tmp = find_var(call_var, 0, "__idivr__", NULL);  // 整除
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3465,7 +3508,7 @@ GWARF_result pow_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__pow__");
+        var *tmp = find_var(call_var, 0, "__pow__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3478,7 +3521,7 @@ GWARF_result pow_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__powr__");
+        var *tmp = find_var(call_var, 0, "__powr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3531,7 +3574,7 @@ GWARF_result log_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__log__");
+        var *tmp = find_var(call_var, 0, "__log__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3544,7 +3587,7 @@ GWARF_result log_func(GWARF_result left_result, GWARF_result right_result, var_l
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__logr__");
+        var *tmp = find_var(call_var, 0, "__logr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3597,7 +3640,7 @@ GWARF_result sqrt_func(GWARF_result left_result, GWARF_result right_result, var_
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__sqrt__");
+        var *tmp = find_var(call_var, 0, "__sqrt__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3610,7 +3653,7 @@ GWARF_result sqrt_func(GWARF_result left_result, GWARF_result right_result, var_
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, "__sqrtr__");
+        var *tmp = find_var(call_var, 0, "__sqrtr__", NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3673,7 +3716,7 @@ GWARF_result equal_func(GWARF_result left_result, GWARF_result right_result, var
         GWARF_value base_the_var = left_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, left_func_list[type]);
+        var *tmp = find_var(call_var, 0, left_func_list[type], NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
@@ -3686,7 +3729,7 @@ GWARF_result equal_func(GWARF_result left_result, GWARF_result right_result, var
         GWARF_value base_the_var = right_result.value;  // 只有一个参数
         var_list *call_var = base_the_var.value.object_value->the_var;
 
-        var *tmp = find_var(call_var, 0, right_func_list[type]);
+        var *tmp = find_var(call_var, 0, right_func_list[type], NULL);
         if(tmp != NULL){
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father

+ 10 - 1
inter/interpreter.h

@@ -78,6 +78,7 @@ typedef struct var{
         auto_public,  // 自动权限
         public,
         protect,
+        private,
     } lock;
     char *name;  // var name
     GWARF_value value;
@@ -211,6 +212,7 @@ typedef struct statement{
                 auto_token,  // 默认情况下auto_token是具有权限访问protetc base_var的,但不具有权限修改protect var,使用point运算符时会修改auto_token
                 public_token,
                 protect_token,
+                private_token,
             } lock_token;  // 如果用于赋值,则是新变量的权限,如果用于读取则是访问的权限 [默认情况 base_var访问权限不受限制,point的时候会更正访问权限]
         } base_var;
 
@@ -419,6 +421,13 @@ typedef struct var_list{
     struct hash_var *hash_var_base;
     struct default_var *default_list;
     struct var_list *next;
+    enum{
+        run_func,
+        run_while,
+        run_if,
+        run_class,
+        run_object,
+    } tag;  // var_list的标签
 } var_list;
 
 // ------------------------- inter paser [记录每一层变量code的链表]
@@ -695,7 +704,7 @@ var_list *append_var_list(hash_var *, var_list *);
 var_list *append_by_var_list(var_list *, var_list *);
 var_list *free_var_list(var_list *);
 int get_var_list_len(var_list *);
-var *find_var(var_list *,int , char *);
+var *find_var(var_list *,int , char *, int *);
 void add_var(var_list *,int , char *, GWARF_value, int);
 void del_var_var_list(var_list *,int, char *);
 var_list *copy_var_list(var_list *);

+ 9 - 3
inter/var.c

@@ -30,7 +30,7 @@ void append_var(char *name, GWARF_value value, var *base_var, int lock){
         tmp = tmp->next;  // get the next to iter
     }
     if(break_ == 2){
-        if(tmp->lock == lock || tmp->lock != protect){  // 检查是否具有修改的权限
+        if(tmp->lock == lock || tmp->lock == public || (tmp->lock == protect && lock == private_token)){  // 检查是否具有修改的权限
             tmp->value = value;
             if(lock != auto_public){  // 检查是否可以改变权限
                 tmp->lock = lock;
@@ -214,6 +214,7 @@ var_list *make_var_list(){  // make a empty var_list node
     tmp = malloc(sizeof(var_list));  // get an address for base var
     tmp->next = NULL;
     tmp->hash_var_base = NULL;
+    tmp->tag = run_func;
     tmp->default_list = make_default_var_base();
     return tmp;
 }
@@ -265,7 +266,7 @@ int get_var_list_len(var_list *var_base){
     return tmp;
 }
 
-var *find_var(var_list *var_base,int from, char *name){  // find var by func get_var in var_list[iter to find]
+var *find_var(var_list *var_base, int from, char *name, int *index){  // index表示层数
     var_list *start = var_base;
     var *return_var;
     from += get_default(name, var_base->default_list);
@@ -275,6 +276,9 @@ var *find_var(var_list *var_base,int from, char *name){  // find var by func get
         }
         start = start->next;
     }
+    if(index != NULL){
+        *index = from;
+    }
     // printf("name = %s, from = %d, address = %x\n", name, from, start->var_base);
     while (1)
     {
@@ -284,9 +288,11 @@ var *find_var(var_list *var_base,int from, char *name){  // find var by func get
         }
         else if((return_var == NULL) && (start->next != NULL)){  // don't get the var but can next
             start = start->next;
+            if(index != NULL){
+                *index += 1;
+            }
             continue;
         }
-        // printf("find on name = %s, from = %d, address = %x\n", name, from, start->var_base);
         return return_var;  //get var success can or can't next
     }
 }

+ 1 - 0
paser/lexical.c

@@ -179,6 +179,7 @@ int paser(int *index, p_status *status){
         match_text(p, global_paser[INLINE_PASER], "inline");
         match_text(p, global_paser[PROTECT_PASER], "protect");
         match_text(p, global_paser[PUBLIC_PASER], "public");
+        match_text(p, global_paser[PRIVATE_PASER], "private");
 
         *index = check_list(global_paser, p, status);  // 检查解析结果
 

+ 6 - 2
paser/syntax.c

@@ -2564,7 +2564,7 @@ void element(p_status *status, token_node *list){  // 数字归约
         add_node(list, new_token);  // 压入节点
         return;
     }
-    else if(gett.type == VAR_PASER || gett.type == PROTECT_PASER || gett.type == PUBLIC_PASER){  // a
+    else if(gett.type == VAR_PASER || gett.type == PROTECT_PASER || gett.type == PUBLIC_PASER || gett.type == PRIVATE_PASER){  // a
         back_one_token(list, gett);
         get_base_token(status, list, var_token, new_token);
         if(new_token.type != NON_base_var){
@@ -2842,7 +2842,7 @@ void var_token(p_status *status, token_node *list){  // 数字归约
     token gett, new_token;
     int lock = auto_token;
     gett = pop_node(list);  // 取得一个token
-    if(gett.type == VAR_PASER || gett.type == PROTECT_PASER || gett.type == PUBLIC_PASER){  // var类型
+    if(gett.type == VAR_PASER || gett.type == PROTECT_PASER || gett.type == PUBLIC_PASER || gett.type == PRIVATE_PASER){  // var类型
         if(gett.type != VAR_PASER){
             switch (gett.type)
             {
@@ -2854,6 +2854,10 @@ void var_token(p_status *status, token_node *list){  // 数字归约
                 lock = public_token;
                 break;
 
+            case PRIVATE_PASER:
+                lock = private_token;
+                break;
+
             default:
                 break;
             }

+ 2 - 1
paser/token.h

@@ -3,7 +3,7 @@
 
 #include "../inter/interpreter.h"
 
-#define MAX_PASER_SIZE 92
+#define MAX_PASER_SIZE 93
 #define INT_PASER 0
 #define DOUBLE_PASER 1
 #define ENTER_PASER 2
@@ -96,6 +96,7 @@
 #define INLINE_PASER 89
 #define PROTECT_PASER 90
 #define PUBLIC_PASER 91
+#define PRIVATE_PASER 92
 
 // 获取并返回一个token
 #define get_pop_token(status,list,new_token) \