diff options
Diffstat (limited to 'src/vim9cmds.c')
-rw-r--r-- | src/vim9cmds.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 080674d2c9..2b7c24d842 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1685,6 +1685,27 @@ compile_eval(char_u *arg, cctx_T *cctx) } /* + * Get the local variable index for deferred function calls. + * Reserve it when not done already. + * Returns zero for failure. + */ + int +get_defer_var_idx(cctx_T *cctx) +{ + dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + + cctx->ctx_ufunc->uf_dfunc_idx; + if (dfunc->df_defer_var_idx == 0) + { + lvar_T *lvar = reserve_local(cctx, (char_u *)"@defer@", 7, + TRUE, &t_list_any); + if (lvar == NULL) + return 0; + dfunc->df_defer_var_idx = lvar->lv_idx + 1; + } + return dfunc->df_defer_var_idx; +} + +/* * Compile "defer func(arg)". */ char_u * |