diff src/vim9instr.c @ 27376:1a6421c5be20 v8.2.4216

patch 8.2.4216: Vim9: cannot use a function from an autoload import directly Commit: https://github.com/vim/vim/commit/06b77229ca704d00c4f138ed0377556e54d5851f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 25 15:51:56 2022 +0000 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly Problem: Vim9: cannot use a function from an autoload import directly. Solution: Add the AUTOLOAD instruction to figure out at runtime. (closes #9620)
author Bram Moolenaar <Bram@vim.org>
date Tue, 25 Jan 2022 17:00:06 +0100
parents 9a9c34c84cd4
children 4c1bdee75bed
line wrap: on
line diff
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -744,6 +744,23 @@ generate_PUSHFUNC(cctx_T *cctx, char_u *
 }
 
 /*
+ * Generate an ISN_AUTOLOAD instruction.
+ */
+    int
+generate_AUTOLOAD(cctx_T *cctx, char_u *name, type_T *type)
+{
+    isn_T	*isn;
+
+    RETURN_OK_IF_SKIP(cctx);
+    if ((isn = generate_instr_type(cctx, ISN_AUTOLOAD, type)) == NULL)
+	return FAIL;
+    isn->isn_arg.string = vim_strsave(name);
+    if (isn->isn_arg.string == NULL)
+	return FAIL;
+    return OK;
+}
+
+/*
  * Generate an ISN_GETITEM instruction with "index".
  * "with_op" is TRUE for "+=" and other operators, the stack has the current
  * value below the list with values.
@@ -1929,6 +1946,7 @@ delete_instr(isn_T *isn)
 {
     switch (isn->isn_type)
     {
+	case ISN_AUTOLOAD:
 	case ISN_DEF:
 	case ISN_EXEC:
 	case ISN_EXECRANGE: