mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 07:18:17 +00:00
refactor: change remaining sourcing_name/sourcing_lnum to exestack
Co-Authored-By: VVKot <volodymyr.kot.ua@gmail.com>
This commit is contained in:
@@ -8614,8 +8614,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments, boo
|
||||
struct caller_scope saved_provider_caller_scope = provider_caller_scope;
|
||||
provider_caller_scope = (struct caller_scope) {
|
||||
.script_ctx = current_sctx,
|
||||
.sourcing_name = SOURCING_NAME,
|
||||
.sourcing_lnum = SOURCING_LNUM,
|
||||
.es_entry = ((estack_T *)exestack.ga_data)[exestack.ga_len - 1],
|
||||
.autocmd_fname = autocmd_fname,
|
||||
.autocmd_match = autocmd_match,
|
||||
.autocmd_bufnr = autocmd_bufnr,
|
||||
|
@@ -7293,7 +7293,6 @@ static void f_rpcnotify(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
/// "rpcrequest()" function
|
||||
static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
#if 0 // TODO:
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->vval.v_number = 0;
|
||||
const int l_provider_call_nesting = provider_call_nesting;
|
||||
@@ -7319,8 +7318,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
sctx_T save_current_sctx;
|
||||
char *save_sourcing_name, *save_autocmd_fname, *save_autocmd_match;
|
||||
linenr_T save_sourcing_lnum;
|
||||
char *save_autocmd_fname, *save_autocmd_match;
|
||||
int save_autocmd_bufnr;
|
||||
funccal_entry_T funccal_entry;
|
||||
|
||||
@@ -7328,16 +7326,14 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
// If this is called from a provider function, restore the scope
|
||||
// information of the caller.
|
||||
save_current_sctx = current_sctx;
|
||||
save_sourcing_name = sourcing_name;
|
||||
save_sourcing_lnum = sourcing_lnum;
|
||||
save_autocmd_fname = autocmd_fname;
|
||||
save_autocmd_match = autocmd_match;
|
||||
save_autocmd_bufnr = autocmd_bufnr;
|
||||
save_funccal(&funccal_entry);
|
||||
|
||||
current_sctx = provider_caller_scope.script_ctx;
|
||||
sourcing_name = provider_caller_scope.sourcing_name;
|
||||
sourcing_lnum = provider_caller_scope.sourcing_lnum;
|
||||
ga_grow(&exestack, 1);
|
||||
((estack_T *)exestack.ga_data)[exestack.ga_len++] = provider_caller_scope.es_entry;
|
||||
autocmd_fname = provider_caller_scope.autocmd_fname;
|
||||
autocmd_match = provider_caller_scope.autocmd_match;
|
||||
autocmd_bufnr = provider_caller_scope.autocmd_bufnr;
|
||||
@@ -7354,8 +7350,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
if (l_provider_call_nesting) {
|
||||
current_sctx = save_current_sctx;
|
||||
sourcing_name = save_sourcing_name;
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
exestack.ga_len--;
|
||||
autocmd_fname = save_autocmd_fname;
|
||||
autocmd_match = save_autocmd_match;
|
||||
autocmd_bufnr = save_autocmd_bufnr;
|
||||
@@ -7387,7 +7382,6 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
end:
|
||||
arena_mem_free(res_mem, NULL);
|
||||
api_clear_error(&err);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// "rpcstart()" function (DEPRECATED)
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/menu.h"
|
||||
#include "nvim/os/os_defs.h"
|
||||
#include "nvim/runtime.h"
|
||||
#include "nvim/syntax_defs.h"
|
||||
#include "nvim/types.h"
|
||||
|
||||
@@ -345,8 +346,8 @@ EXTERN bool did_source_packages INIT(= false);
|
||||
// provider function call
|
||||
EXTERN struct caller_scope {
|
||||
sctx_T script_ctx;
|
||||
char *sourcing_name, *autocmd_fname, *autocmd_match;
|
||||
linenr_T sourcing_lnum;
|
||||
estack_T es_entry;
|
||||
char *autocmd_fname, *autocmd_match;
|
||||
int autocmd_bufnr;
|
||||
void *funccalp;
|
||||
} provider_caller_scope;
|
||||
|
@@ -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
|
||||
|
@@ -1731,19 +1731,19 @@ scriptitem_T *new_script_item(char *const name, scid_T *const sid_out)
|
||||
|
||||
static int source_using_linegetter(void *cookie, LineGetter fgetline, const char *traceback_name)
|
||||
{
|
||||
#if 0 // TODO:
|
||||
char *save_sourcing_name = sourcing_name;
|
||||
linenr_T save_sourcing_lnum = sourcing_lnum;
|
||||
char *save_sourcing_name = SOURCING_NAME;
|
||||
linenr_T save_sourcing_lnum = SOURCING_LNUM;
|
||||
char sourcing_name_buf[256];
|
||||
char *sname;
|
||||
if (save_sourcing_name == NULL) {
|
||||
sourcing_name = (char *)traceback_name;
|
||||
sname = (char *)traceback_name;
|
||||
} else {
|
||||
snprintf((char *)sourcing_name_buf, sizeof(sourcing_name_buf),
|
||||
"%s called at %s:%" PRIdLINENR, traceback_name, save_sourcing_name,
|
||||
save_sourcing_lnum);
|
||||
sourcing_name = sourcing_name_buf; // -V507 reassigned below, before return.
|
||||
sname = sourcing_name_buf;
|
||||
}
|
||||
sourcing_lnum = 0;
|
||||
estack_push(ETYPE_SCRIPT, sname, 0);
|
||||
|
||||
const sctx_T save_current_sctx = current_sctx;
|
||||
if (current_sctx.sc_sid != SID_LUA) {
|
||||
@@ -1755,12 +1755,10 @@ static int source_using_linegetter(void *cookie, LineGetter fgetline, const char
|
||||
save_funccal(&entry);
|
||||
int retval = do_cmdline(NULL, fgetline, cookie,
|
||||
DOCMD_VERBOSE | DOCMD_NOWAIT | DOCMD_REPEAT);
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
sourcing_name = save_sourcing_name;
|
||||
estack_pop();
|
||||
current_sctx = save_current_sctx;
|
||||
restore_funccal();
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cmd_source_buffer(const exarg_T *const eap)
|
||||
@@ -1982,17 +1980,14 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
}
|
||||
|
||||
if (path_with_extension((const char *)fname_exp, "lua")) {
|
||||
#if 0 // TODO:
|
||||
const sctx_T current_sctx_backup = current_sctx;
|
||||
const linenr_T sourcing_lnum_backup = sourcing_lnum;
|
||||
current_sctx.sc_sid = SID_LUA;
|
||||
current_sctx.sc_lnum = 0;
|
||||
sourcing_lnum = 0;
|
||||
estack_push(ETYPE_SCRIPT, NULL, 0);
|
||||
// Source the file as lua
|
||||
nlua_exec_file((const char *)fname_exp);
|
||||
current_sctx = current_sctx_backup;
|
||||
sourcing_lnum = sourcing_lnum_backup;
|
||||
#endif
|
||||
estack_pop();
|
||||
} else {
|
||||
// Call do_cmdline, which will call getsourceline() to get the lines.
|
||||
do_cmdline((char *)firstline, getsourceline, (void *)&cookie,
|
||||
|
@@ -8,20 +8,20 @@
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
#include "nvim/ex_eval_defs.h"
|
||||
|
||||
/// Entry in the execution stack "exestack".
|
||||
typedef enum {
|
||||
ETYPE_TOP, // toplevel
|
||||
ETYPE_SCRIPT, // sourcing script, use es_info.sctx
|
||||
ETYPE_UFUNC, // user function, use es_info.ufunc
|
||||
ETYPE_AUCMD, // autocomand, use es_info.aucmd
|
||||
ETYPE_MODELINE, // modeline, use es_info.sctx
|
||||
ETYPE_EXCEPT, // exception, use es_info.exception
|
||||
ETYPE_ARGS, // command line argument
|
||||
ETYPE_ENV, // environment variable
|
||||
ETYPE_INTERNAL, // internal operation
|
||||
ETYPE_SPELL, // loading spell file
|
||||
ETYPE_TOP, ///< toplevel
|
||||
ETYPE_SCRIPT, ///< sourcing script, use es_info.sctx
|
||||
ETYPE_UFUNC, ///< user function, use es_info.ufunc
|
||||
ETYPE_AUCMD, ///< autocomand, use es_info.aucmd
|
||||
ETYPE_MODELINE, ///< modeline, use es_info.sctx
|
||||
ETYPE_EXCEPT, ///< exception, use es_info.exception
|
||||
ETYPE_ARGS, ///< command line argument
|
||||
ETYPE_ENV, ///< environment variable
|
||||
ETYPE_INTERNAL, ///< internal operation
|
||||
ETYPE_SPELL, ///< loading spell file
|
||||
} etype_T;
|
||||
|
||||
/// Entry in the execution stack "exestack".
|
||||
typedef struct {
|
||||
linenr_T es_lnum; ///< replaces "sourcing_lnum"
|
||||
char *es_name; ///< replaces "sourcing_name"
|
||||
|
Reference in New Issue
Block a user