]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1952: Vim9: unused static field v9.0.1952
authorYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 29 Sep 2023 17:43:11 +0000 (19:43 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 29 Sep 2023 17:44:25 +0000 (19:44 +0200)
Problem:  Vim9: unused static field
Solution: remove it and simplify code

closes: #13220

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
src/proto/vim9class.pro
src/proto/vim9instr.pro
src/version.c
src/vim9.h
src/vim9class.c
src/vim9compile.c
src/vim9execute.c
src/vim9expr.c
src/vim9instr.c

index d09f6545703bf634bd2f0a672c9088df8945171f..9edf35408e8ca43df563038d1687644f12e7ac15 100644 (file)
@@ -1,5 +1,5 @@
 /* vim9class.c */
-int object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl, int is_static);
+int object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl);
 void ex_class(exarg_T *eap);
 type_T *class_member_type(class_T *cl, int is_object, char_u *name, char_u *name_end, int *member_idx);
 void ex_enum(exarg_T *eap);
index 44e6b98f30c222e11b332dd347bd5d6aa624b040..7c13f93336ffe8788544276cddb60acd49251520 100644 (file)
@@ -4,8 +4,8 @@ isn_T *generate_instr_drop(cctx_T *cctx, isntype_T isn_type, int drop);
 isn_T *generate_instr_type(cctx_T *cctx, isntype_T isn_type, type_T *type);
 isn_T *generate_instr_debug(cctx_T *cctx);
 int generate_CONSTRUCT(cctx_T *cctx, class_T *cl);
-int generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static);
-int generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type, int is_static);
+int generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type);
+int generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type);
 int generate_STORE_THIS(cctx_T *cctx, int idx);
 int may_generate_2STRING(int offset, int tolerant, cctx_T *cctx);
 int generate_add_instr(cctx_T *cctx, vartype_T vartype, type_T *type1, type_T *type2, exprtype_T expr_type);
index 5aca53a45a2ddfc82d77f52485f6ee155aa7e1ff..ad696de122054e9a20c201454c2f37542e376acc 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1952,
 /**/
     1951,
 /**/
index bafff94fde1b0111a25a828d6e21c9b7f7167c26..03f6dade60d9b1e234161386274765d354b6c901 100644 (file)
@@ -498,7 +498,6 @@ typedef struct {
 typedef struct {
     class_T    *cm_class;
     int                cm_idx;
-    int                cm_static;
 } classmember_T;
 // arguments to ISN_STOREINDEX
 typedef struct {
index 29ed6d1b8e3aa3ccaf3974999ddcd442356d5cc0..885ac0385ca1ebd236779fd491d2996bf41c6a56 100644 (file)
@@ -220,12 +220,10 @@ add_members_to_class(
  * "cl" implementing that interface.
  */
     int
-object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
-                                                               int is_static)
+object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl)
 {
     if (idx >= (is_method ? itf->class_obj_method_count
-                                  : is_static ? itf->class_class_member_count
-                                               : itf->class_obj_member_count))
+                                  : itf->class_obj_member_count))
     {
        siemsg("index %d out of range for interface %s", idx, itf->class_name);
        return 0;
@@ -255,9 +253,7 @@ object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
        if (searching && is_method)
            // The parent class methods are stored after the current class
            // methods.
-           method_offset += is_static
-                               ? super->class_class_function_count_child
-                               : super->class_obj_method_count_child;
+           method_offset += super->class_obj_method_count_child;
     }
     if (i2c == NULL)
     {
@@ -265,26 +261,12 @@ object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
                                              cl->class_name, itf->class_name);
        return 0;
     }
-    if (is_static)
-    {
-       // TODO: Need a table for fast lookup?
-       char_u *name = itf->class_class_members[idx].ocm_name;
-       int     m_idx = class_member_idx(i2c->i2c_class, name, 0);
-       if (m_idx >= 0)
-           return m_idx;
 
-       siemsg("class %s, interface %s, static %s not found",
-                                     cl->class_name, itf->class_name, name);
-       return 0;
-    }
-    else
-    {
-       // A table follows the i2c for the class
-       int *table = (int *)(i2c + 1);
-       // "method_offset" is 0, if method is in the current class.  If method
-       // is in a parent class, then it is non-zero.
-       return table[idx] + method_offset;
-    }
+    // A table follows the i2c for the class
+    int *table = (int *)(i2c + 1);
+    // "method_offset" is 0, if method is in the current class.  If method
+    // is in a parent class, then it is non-zero.
+    return table[idx] + method_offset;
 }
 
 /*
index 40fdc4bdd4dd565f3d098924a0b974a24c1414df..086a322caae27d23f68e60cee7986ee96a08fed7 100644 (file)
@@ -2249,9 +2249,8 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u *var_start, cctx_T *cctx)
                return FAIL;
        }
        if (cl->class_flags & CLASS_INTERFACE)
-           return generate_GET_ITF_MEMBER(cctx, cl, lhs->lhs_member_idx, type,
-                                                                       FALSE);
-       return generate_GET_OBJ_MEMBER(cctx, lhs->lhs_member_idx, type, FALSE);
+           return generate_GET_ITF_MEMBER(cctx, cl, lhs->lhs_member_idx, type);
+       return generate_GET_OBJ_MEMBER(cctx, lhs->lhs_member_idx, type);
     }
 
     compile_load_lhs(lhs, var_start, NULL, cctx);
index 0700eb78094b301ce0b9e828ffeea25ecc0392e0..d005deb4d7283d4fb5cf42b1ed2095fcd77d65d8 100644 (file)
@@ -2318,7 +2318,7 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
                if (itf != NULL)
                    // convert interface member index to class member index
                    lidx = object_index_from_itf_index(itf, FALSE, lidx,
-                                                      obj->obj_class, FALSE);
+                                                      obj->obj_class);
            }
            else
            {
@@ -4262,8 +4262,7 @@ exec_instructions(ectx_T *ectx)
 
                    // convert the interface index to the object index
                    int idx = object_index_from_itf_index(mfunc->cmf_itf,
-                                                   TRUE, mfunc->cmf_idx, cl,
-                                                   FALSE);
+                                                   TRUE, mfunc->cmf_idx, cl);
 
                    if (call_ufunc(cl->class_obj_methods[idx], NULL,
                                mfunc->cmf_argcount, ectx, NULL, NULL) == FAIL)
@@ -4412,8 +4411,7 @@ exec_instructions(ectx_T *ectx)
 
                        // convert the interface index to the object index
                        int idx = object_index_from_itf_index(extra->fre_class,
-                                             TRUE, extra->fre_method_idx, cl,
-                                             FALSE);
+                                             TRUE, extra->fre_method_idx, cl);
                        ufunc = cl->class_obj_methods[idx];
                    }
                    else if (extra == NULL || extra->fre_func_name == NULL)
@@ -5392,7 +5390,6 @@ exec_instructions(ectx_T *ectx)
                        goto on_error;
                    }
 
-                   int is_static = iptr->isn_arg.classmember.cm_static;
                    int idx;
                    if (iptr->isn_type == ISN_GET_OBJ_MEMBER)
                        idx = iptr->isn_arg.classmember.cm_idx;
@@ -5402,15 +5399,11 @@ exec_instructions(ectx_T *ectx)
                        // convert the interface index to the object index
                        idx = object_index_from_itf_index(
                                        iptr->isn_arg.classmember.cm_class,
-                                       FALSE, idx, obj->obj_class, is_static);
+                                       FALSE, idx, obj->obj_class);
                    }
 
                    // The members are located right after the object struct.
-                   typval_T *mtv;
-                   if (is_static)
-                       mtv = &obj->obj_class->class_members_tv[idx];
-                   else
-                       mtv = ((typval_T *)(obj + 1)) + idx;
+                   typval_T *mtv = ((typval_T *)(obj + 1)) + idx;
                    copy_tv(mtv, tv);
 
                    // Unreference the object after getting the member, it may
@@ -7157,17 +7150,13 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
            case ISN_MEMBER: smsg("%s%4d MEMBER", pfx, current); break;
            case ISN_STRINGMEMBER: smsg("%s%4d MEMBER %s", pfx, current,
                                                  iptr->isn_arg.string); break;
-           case ISN_GET_OBJ_MEMBER: smsg("%s%4d OBJ_MEMBER %d%s", pfx, current,
-                            (int)iptr->isn_arg.classmember.cm_idx,
-                            iptr->isn_arg.classmember.cm_static
-                                                       ? " [STATIC]" : "");
+           case ISN_GET_OBJ_MEMBER: smsg("%s%4d OBJ_MEMBER %d", pfx, current,
+                            (int)iptr->isn_arg.classmember.cm_idx);
                                     break;
-           case ISN_GET_ITF_MEMBER: smsg("%s%4d ITF_MEMBER %d on %s%s",
+           case ISN_GET_ITF_MEMBER: smsg("%s%4d ITF_MEMBER %d on %s",
                             pfx, current,
                             (int)iptr->isn_arg.classmember.cm_idx,
-                            iptr->isn_arg.classmember.cm_class->class_name,
-                            iptr->isn_arg.classmember.cm_static
-                                                       ? " [STATIC]" : "");
+                            iptr->isn_arg.classmember.cm_class->class_name);
                                     break;
            case ISN_STORE_THIS: smsg("%s%4d STORE_THIS %d", pfx, current,
                                             (int)iptr->isn_arg.number); break;
index 7abd0a4d3725665fbd36e5212b7453d0cfe3fa82..5a302d68843f596fb8eb62371c52d13d727f836a 100644 (file)
@@ -413,9 +413,8 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
 
            *arg = name_end;
            if (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))
-               return generate_GET_ITF_MEMBER(cctx, cl, m_idx, m->ocm_type,
-                                                                       FALSE);
-           return generate_GET_OBJ_MEMBER(cctx, m_idx, m->ocm_type, FALSE);
+               return generate_GET_ITF_MEMBER(cctx, cl, m_idx, m->ocm_type);
+           return generate_GET_OBJ_MEMBER(cctx, m_idx, m->ocm_type);
        }
 
        // Could be a function reference: "obj.Func".
index 48b4ea404695e3ce79367a5cb3193c22b6f9ef51..b229d4a11939768248fe7f4999025d8bd444b30d 100644 (file)
@@ -136,7 +136,7 @@ generate_CONSTRUCT(cctx_T *cctx, class_T *cl)
  * index.
  */
     int
-generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static)
+generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type)
 {
     RETURN_OK_IF_SKIP(cctx);
 
@@ -147,7 +147,6 @@ generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static)
 
     isn->isn_arg.classmember.cm_class = NULL;
     isn->isn_arg.classmember.cm_idx = idx;
-    isn->isn_arg.classmember.cm_static = is_static;
     return push_type_stack2(cctx, type, &t_any);
 }
 
@@ -156,8 +155,7 @@ generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static)
  * by index.
  */
     int
-generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type,
-                                                               int is_static)
+generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type)
 {
     RETURN_OK_IF_SKIP(cctx);
 
@@ -169,7 +167,6 @@ generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type,
     isn->isn_arg.classmember.cm_class = itf;
     ++itf->class_refcount;
     isn->isn_arg.classmember.cm_idx = idx;
-    isn->isn_arg.classmember.cm_static = is_static;
     return push_type_stack2(cctx, type, &t_any);
 }