diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:05:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:05:19 +0000 |
commit | a4e9136f68a40b1cb0eb6df5a5f06603224a87f4 (patch) | |
tree | ba32e0d0069ad6adfd6b32d05161a03eea5e4c7c /src/vim9execute.c | |
parent | Releasing progress-linux version 2:9.1.0496-1~progress7.99u1. (diff) | |
download | vim-a4e9136f68a40b1cb0eb6df5a5f06603224a87f4.tar.xz vim-a4e9136f68a40b1cb0eb6df5a5f06603224a87f4.zip |
Merging upstream version 2:9.1.0698.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/vim9execute.c | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c index 3a3960a..f523e27 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2254,26 +2254,35 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx) { // Need to get the member index now that the class is known. object_T *obj = tv_dest->vval.v_object; - class_T *cl = obj->obj_class; - char_u *member = tv_idx->vval.v_string; - - int m_idx; - ocmember_T *m = object_member_lookup(cl, member, 0, &m_idx); - if (m != NULL) + if (obj == NULL) { - if (*member == '_') - { - emsg_var_cl_define(e_cannot_access_protected_variable_str, - m->ocm_name, 0, cl); - status = FAIL; - } - - lidx = m_idx; + emsg(_(e_using_null_object)); + status = FAIL; } else { - member_not_found_msg(cl, VAR_OBJECT, member, 0); - status = FAIL; + class_T *cl = obj->obj_class; + char_u *member = tv_idx->vval.v_string; + + int m_idx; + ocmember_T *m = object_member_lookup(cl, member, 0, &m_idx); + if (m != NULL) + { + if (*member == '_') + { + emsg_var_cl_define( + e_cannot_access_protected_variable_str, + m->ocm_name, 0, cl); + status = FAIL; + } + + lidx = m_idx; + } + else + { + member_not_found_msg(cl, VAR_OBJECT, member, 0); + status = FAIL; + } } } else if ((dest_type == VAR_LIST || dest_type == VAR_OBJECT) @@ -3567,7 +3576,10 @@ exec_instructions(ectx_T *ectx) p = tv_get_string_buf(tv, buf); } else + { + SOURCING_LNUM = iptr->isn_lnum; p = tv_stringify(tv, buf); + } len = (int)STRLEN(p); if (GA_GROW_FAILS(&ga, len + 2)) @@ -4380,15 +4392,31 @@ exec_instructions(ectx_T *ectx) object_required_error(tv); goto on_error; } + object_T *obj = tv->vval.v_object; - class_T *cl = obj->obj_class; + if (obj == NULL) + { + emsg(_(e_using_null_object)); + goto on_error; + } - // convert the interface index to the object index - int idx = object_index_from_itf_index(mfunc->cmf_itf, - TRUE, mfunc->cmf_idx, cl); + ufunc_T *ufunc; + if (mfunc->cmf_is_super) + // Doing "super.Func", use the specific ufunc. + ufunc = mfunc->cmf_itf->class_obj_methods[ + mfunc->cmf_idx]; + else + { + class_T *cl = obj->obj_class; - if (call_ufunc(cl->class_obj_methods[idx], NULL, - mfunc->cmf_argcount, ectx, NULL, NULL) == FAIL) + // convert the interface index to the object index + int idx = object_index_from_itf_index(mfunc->cmf_itf, + TRUE, mfunc->cmf_idx, cl); + ufunc = cl->class_obj_methods[idx]; + } + + if (call_ufunc(ufunc, NULL, mfunc->cmf_argcount, ectx, + NULL, NULL) == FAIL) goto on_error; } break; @@ -4536,12 +4564,21 @@ exec_instructions(ectx_T *ectx) tv = STACK_TV_BOT(-1); if (tv->v_type != VAR_OBJECT) { + SOURCING_LNUM = iptr->isn_lnum; object_required_error(tv); vim_free(pt); goto on_error; } object_T *obj = tv->vval.v_object; + if (obj == NULL) + { + SOURCING_LNUM = iptr->isn_lnum; + emsg(_(e_using_null_object)); + vim_free(pt); + goto on_error; + } + cl = obj->obj_class; // drop the value from the stack clear_tv(tv); |