From f52c236c5b432629f0e074c3511e7e9d481197b1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 13:48:11 +0800 Subject: vim-patch:8.2.0056: execution stack is incomplete and inefficient Problem: Execution stack is incomplete and inefficient. Solution: Introduce a proper execution stack and use it instead of sourcing_name/sourcing_lnum. Create a string only when used. https://github.com/vim/vim/commit/1a47ae32cdc19b0fd5a82e19fe5fddf45db1a506 Omit test_debugger.vim: superseded by later patches. Omit check_map_keycodes(): N/A. Omit kword_test.c: N/A (converted to a unit test). --- src/nvim/lua/executor.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 2ce564c011..342b3f6c67 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1313,6 +1313,7 @@ static void nlua_typval_exec(const char *lcmd, size_t lcmd_len, const char *name int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name) { +#if 0 // TODO: const linenr_T save_sourcing_lnum = sourcing_lnum; const sctx_T save_current_sctx = current_sctx; current_sctx.sc_sid = SID_STR; @@ -1336,6 +1337,7 @@ int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name) ga_clear_strings(&ga); xfree(code); return OK; +#endif } /// Call a LuaCallable given some typvals -- cgit From ded2925b406f55223f6093544bc3a38534c1e72e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 16:07:05 +0800 Subject: refactor: change remaining sourcing_name/sourcing_lnum to exestack Co-Authored-By: VVKot --- src/nvim/lua/executor.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 342b3f6c67..2e5b411fad 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -37,6 +37,7 @@ #include "nvim/msgpack_rpc/channel.h" #include "nvim/os/os.h" #include "nvim/profile.h" +#include "nvim/runtime.h" #include "nvim/screen.h" #include "nvim/undo.h" #include "nvim/usercmd.h" @@ -1313,13 +1314,11 @@ static void nlua_typval_exec(const char *lcmd, size_t lcmd_len, const char *name int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name) { -#if 0 // TODO: - const linenr_T save_sourcing_lnum = sourcing_lnum; const sctx_T save_current_sctx = current_sctx; current_sctx.sc_sid = SID_STR; current_sctx.sc_seq = 0; current_sctx.sc_lnum = 0; - sourcing_lnum = 0; + estack_push(ETYPE_SCRIPT, NULL, 0); garray_T ga; char_u *line = NULL; @@ -1332,12 +1331,11 @@ int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name) size_t len = strlen(code); nlua_typval_exec(code, len, name, NULL, 0, false, NULL); - sourcing_lnum = save_sourcing_lnum; + estack_pop(); current_sctx = save_current_sctx; ga_clear_strings(&ga); xfree(code); return OK; -#endif } /// Call a LuaCallable given some typvals -- cgit