patch 9.0.1952: Vim9: unused static field Commit: https://github.com/vim/vim/commit/5a05d374d30577ee195e87e7929062ab1a0a076a Author: Yegappan Lakshmanan <yegap...@yahoo.com> Date: Fri Sep 29 19:43:11 2023 +0200
patch 9.0.1952: Vim9: unused static field Problem: Vim9: unused static field Solution: remove it and simplify code closes: #13220 Signed-off-by: Christian Brabandt <c...@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegap...@yahoo.com> diff --git a/src/proto/vim9class.pro b/src/proto/vim9class.pro index d09f65457..9edf35408 100644 --- a/src/proto/vim9class.pro +++ b/src/proto/vim9class.pro @@ -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); diff --git a/src/proto/vim9instr.pro b/src/proto/vim9instr.pro index 44e6b98f3..7c13f9333 100644 --- a/src/proto/vim9instr.pro +++ b/src/proto/vim9instr.pro @@ -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); diff --git a/src/version.c b/src/version.c index 5aca53a45..ad696de12 100644 --- a/src/version.c +++ b/src/version.c @@ -699,6 +699,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1952, /**/ 1951, /**/ diff --git a/src/vim9.h b/src/vim9.h index bafff94fd..03f6dade6 100644 --- a/src/vim9.h +++ b/src/vim9.h @@ -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 { diff --git a/src/vim9class.c b/src/vim9class.c index 29ed6d1b8..885ac0385 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -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; } /* diff --git a/src/vim9compile.c b/src/vim9compile.c index 40fdc4bdd..086a322ca 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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); diff --git a/src/vim9execute.c b/src/vim9execute.c index 0700eb780..d005deb4d 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -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; diff --git a/src/vim9expr.c b/src/vim9expr.c index 7abd0a4d3..5a302d688 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -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". diff --git a/src/vim9instr.c b/src/vim9instr.c index 48b4ea404..b229d4a11 100644 --- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -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); } -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1qmHY3-00HUA9-8S%40256bit.org.