mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1139: cannot create a new object in a compiled function
Problem: Cannot create a new object in a compiled function. Solution: Compile the instructins to create a new object.
This commit is contained in:
@@ -273,8 +273,47 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
|
||||
class_T *cl = (class_T *)type->tt_member;
|
||||
if (*name_end == '(')
|
||||
{
|
||||
// TODO: method or function call
|
||||
emsg("compile_class_object_index(): object/class call not handled yet");
|
||||
if (type->tt_type == VAR_CLASS)
|
||||
{
|
||||
garray_T *instr = &cctx->ctx_instr;
|
||||
if (instr->ga_len > 0)
|
||||
{
|
||||
isn_T *isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1;
|
||||
if (isn->isn_type == ISN_LOADSCRIPT)
|
||||
{
|
||||
// The class was recognized as a script item. We only need
|
||||
// to know what class it is, drop the instruction.
|
||||
--instr->ga_len;
|
||||
vim_free(isn->isn_arg.script.scriptref);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cl->class_class_function_count; ++i)
|
||||
{
|
||||
ufunc_T *fp = cl->class_class_functions[i];
|
||||
// Use a separate pointer to avoid that ASAN complains about
|
||||
// uf_name[] only being 4 characters.
|
||||
char_u *ufname = (char_u *)fp->uf_name;
|
||||
if (STRNCMP(name, ufname, len) == 0 && ufname[len] == NUL)
|
||||
{
|
||||
*arg = skipwhite(name_end + 1);
|
||||
int argcount = 0;
|
||||
if (compile_arguments(arg, cctx, &argcount,
|
||||
CA_NOT_SPECIAL) == FAIL)
|
||||
return FAIL;
|
||||
return generate_CALL(cctx, fp, argcount);
|
||||
}
|
||||
}
|
||||
|
||||
semsg(_(e_method_not_found_on_class_str_str),
|
||||
cl->class_name, name);
|
||||
return FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: method call
|
||||
emsg("compile_class_object_index(): object call not handled yet");
|
||||
}
|
||||
}
|
||||
else if (type->tt_type == VAR_OBJECT)
|
||||
{
|
||||
|
Reference in New Issue
Block a user