mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Problem: Vim9: cannot load a Vim9 script without the +eval feature. Solution: Support Vim9 script syntax without the +eval feature.
This commit is contained in:
parent
ed1e4c9a70
commit
9b8d62267f
@ -55,9 +55,7 @@ typedef struct AutoCmd
|
|||||||
char once; // "One shot": removed after execution
|
char once; // "One shot": removed after execution
|
||||||
char nested; // If autocommands nest here.
|
char nested; // If autocommands nest here.
|
||||||
char last; // last command in list
|
char last; // last command in list
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sctx_T script_ctx; // script context where defined
|
sctx_T script_ctx; // script context where defined
|
||||||
#endif
|
|
||||||
struct AutoCmd *next; // next AutoCmd in list
|
struct AutoCmd *next; // next AutoCmd in list
|
||||||
} AutoCmd;
|
} AutoCmd;
|
||||||
|
|
||||||
@ -1249,8 +1247,8 @@ do_autocmd_event(
|
|||||||
if (ac == NULL)
|
if (ac == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
ac->cmd = vim_strsave(cmd);
|
ac->cmd = vim_strsave(cmd);
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
ac->script_ctx = current_sctx;
|
ac->script_ctx = current_sctx;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
ac->script_ctx.sc_lnum += SOURCING_LNUM;
|
ac->script_ctx.sc_lnum += SOURCING_LNUM;
|
||||||
#endif
|
#endif
|
||||||
if (ac->cmd == NULL)
|
if (ac->cmd == NULL)
|
||||||
@ -1819,8 +1817,8 @@ apply_autocmds_group(
|
|||||||
static int nesting = 0;
|
static int nesting = 0;
|
||||||
AutoPatCmd patcmd;
|
AutoPatCmd patcmd;
|
||||||
AutoPat *ap;
|
AutoPat *ap;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sctx_T save_current_sctx;
|
sctx_T save_current_sctx;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
funccal_entry_T funccal_entry;
|
funccal_entry_T funccal_entry;
|
||||||
char_u *save_cmdarg;
|
char_u *save_cmdarg;
|
||||||
long save_cmdbang;
|
long save_cmdbang;
|
||||||
@ -2029,9 +2027,9 @@ apply_autocmds_group(
|
|||||||
estack_push(ETYPE_AUCMD, NULL, 0);
|
estack_push(ETYPE_AUCMD, NULL, 0);
|
||||||
ESTACK_CHECK_SETUP
|
ESTACK_CHECK_SETUP
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
save_current_sctx = current_sctx;
|
save_current_sctx = current_sctx;
|
||||||
|
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
# ifdef FEAT_PROFILE
|
# ifdef FEAT_PROFILE
|
||||||
if (do_profiling == PROF_YES)
|
if (do_profiling == PROF_YES)
|
||||||
prof_child_enter(&wait_time); // doesn't count for the caller itself
|
prof_child_enter(&wait_time); // doesn't count for the caller itself
|
||||||
@ -2138,8 +2136,8 @@ apply_autocmds_group(
|
|||||||
autocmd_fname_full = save_autocmd_fname_full;
|
autocmd_fname_full = save_autocmd_fname_full;
|
||||||
autocmd_bufnr = save_autocmd_bufnr;
|
autocmd_bufnr = save_autocmd_bufnr;
|
||||||
autocmd_match = save_autocmd_match;
|
autocmd_match = save_autocmd_match;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
restore_funccal();
|
restore_funccal();
|
||||||
# ifdef FEAT_PROFILE
|
# ifdef FEAT_PROFILE
|
||||||
if (do_profiling == PROF_YES)
|
if (do_profiling == PROF_YES)
|
||||||
@ -2370,9 +2368,7 @@ getnextac(
|
|||||||
if (ac->once)
|
if (ac->once)
|
||||||
au_del_cmd(ac);
|
au_del_cmd(ac);
|
||||||
autocmd_nested = ac->nested;
|
autocmd_nested = ac->nested;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
current_sctx = ac->script_ctx;
|
current_sctx = ac->script_ctx;
|
||||||
#endif
|
|
||||||
if (ac->last)
|
if (ac->last)
|
||||||
acp->nextcmd = NULL;
|
acp->nextcmd = NULL;
|
||||||
else
|
else
|
||||||
|
11
src/buffer.c
11
src/buffer.c
@ -5371,9 +5371,8 @@ chk_modeline(
|
|||||||
int vers;
|
int vers;
|
||||||
int end;
|
int end;
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sctx_T save_current_sctx;
|
sctx_T save_current_sctx;
|
||||||
#endif
|
|
||||||
ESTACK_CHECK_DECLARATION
|
ESTACK_CHECK_DECLARATION
|
||||||
|
|
||||||
prev = -1;
|
prev = -1;
|
||||||
@ -5457,22 +5456,22 @@ chk_modeline(
|
|||||||
if (*s != NUL) // skip over an empty "::"
|
if (*s != NUL) // skip over an empty "::"
|
||||||
{
|
{
|
||||||
int secure_save = secure;
|
int secure_save = secure;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
save_current_sctx = current_sctx;
|
save_current_sctx = current_sctx;
|
||||||
|
current_sctx.sc_version = 1;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
current_sctx.sc_sid = SID_MODELINE;
|
current_sctx.sc_sid = SID_MODELINE;
|
||||||
current_sctx.sc_seq = 0;
|
current_sctx.sc_seq = 0;
|
||||||
current_sctx.sc_lnum = lnum;
|
current_sctx.sc_lnum = lnum;
|
||||||
current_sctx.sc_version = 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make sure no risky things are executed as a side effect.
|
// Make sure no risky things are executed as a side effect.
|
||||||
secure = 1;
|
secure = 1;
|
||||||
|
|
||||||
retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags);
|
retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags);
|
||||||
|
|
||||||
secure = secure_save;
|
secure = secure_save;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
#endif
|
|
||||||
if (retval == FAIL) // stop if error found
|
if (retval == FAIL) // stop if error found
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,10 @@ EXTERN char e_assert_fails_second_arg[]
|
|||||||
INIT(= N_("E856: \"assert_fails()\" second argument must be a string or a list with one or two strings"));
|
INIT(= N_("E856: \"assert_fails()\" second argument must be a string or a list with one or two strings"));
|
||||||
EXTERN char e_cannot_index_special_variable[]
|
EXTERN char e_cannot_index_special_variable[]
|
||||||
INIT(= N_("E909: Cannot index a special variable"));
|
INIT(= N_("E909: Cannot index a special variable"));
|
||||||
EXTERN char e_missing_var_str[]
|
#endif
|
||||||
INIT(= N_("E1100: Missing :var: %s"));
|
EXTERN char e_command_not_supported_in_vim9_script_missing_var_str[]
|
||||||
|
INIT(= N_("E1100: Command not supported in Vim9 script (missing :var?): %s"));
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
EXTERN char e_variable_not_found_str[]
|
EXTERN char e_variable_not_found_str[]
|
||||||
INIT(= N_("E1001: Variable not found: %s"));
|
INIT(= N_("E1001: Variable not found: %s"));
|
||||||
EXTERN char e_syntax_error_at_str[]
|
EXTERN char e_syntax_error_at_str[]
|
||||||
@ -113,8 +115,10 @@ EXTERN char e_vim9script_can_only_be_used_in_script[]
|
|||||||
INIT(= N_("E1038: \"vim9script\" can only be used in a script"));
|
INIT(= N_("E1038: \"vim9script\" can only be used in a script"));
|
||||||
EXTERN char e_vim9script_must_be_first_command_in_script[]
|
EXTERN char e_vim9script_must_be_first_command_in_script[]
|
||||||
INIT(= N_("E1039: \"vim9script\" must be the first command in a script"));
|
INIT(= N_("E1039: \"vim9script\" must be the first command in a script"));
|
||||||
|
#endif
|
||||||
EXTERN char e_cannot_use_scriptversion_after_vim9script[]
|
EXTERN char e_cannot_use_scriptversion_after_vim9script[]
|
||||||
INIT(= N_("E1040: Cannot use :scriptversion after :vim9script"));
|
INIT(= N_("E1040: Cannot use :scriptversion after :vim9script"));
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
EXTERN char e_redefining_script_item_str[]
|
EXTERN char e_redefining_script_item_str[]
|
||||||
INIT(= N_("E1041: Redefining script item %s"));
|
INIT(= N_("E1041: Redefining script item %s"));
|
||||||
EXTERN char e_export_can_only_be_used_in_vim9script[]
|
EXTERN char e_export_can_only_be_used_in_vim9script[]
|
||||||
|
@ -304,7 +304,6 @@ static void ex_tag_cmd(exarg_T *eap, char_u *name);
|
|||||||
# define ex_try ex_ni
|
# define ex_try ex_ni
|
||||||
# define ex_unlet ex_ni
|
# define ex_unlet ex_ni
|
||||||
# define ex_unlockvar ex_ni
|
# define ex_unlockvar ex_ni
|
||||||
# define ex_vim9script ex_ni
|
|
||||||
# define ex_while ex_ni
|
# define ex_while ex_ni
|
||||||
# define ex_import ex_ni
|
# define ex_import ex_ni
|
||||||
# define ex_export ex_ni
|
# define ex_export ex_ni
|
||||||
@ -8011,10 +8010,9 @@ save_current_state(save_state_T *sst)
|
|||||||
msg_scroll = FALSE; // no msg scrolling in Normal mode
|
msg_scroll = FALSE; // no msg scrolling in Normal mode
|
||||||
restart_edit = 0; // don't go to Insert mode
|
restart_edit = 0; // don't go to Insert mode
|
||||||
p_im = FALSE; // don't use 'insertmode'
|
p_im = FALSE; // don't use 'insertmode'
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sst->save_script_version = current_sctx.sc_version;
|
sst->save_script_version = current_sctx.sc_version;
|
||||||
current_sctx.sc_version = 1; // not in Vim9 script
|
current_sctx.sc_version = 1; // not in Vim9 script
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the current typeahead. This is required to allow using ":normal"
|
* Save the current typeahead. This is required to allow using ":normal"
|
||||||
@ -8038,9 +8036,7 @@ restore_current_state(save_state_T *sst)
|
|||||||
opcount = sst->save_opcount;
|
opcount = sst->save_opcount;
|
||||||
reg_executing = sst->save_reg_executing;
|
reg_executing = sst->save_reg_executing;
|
||||||
msg_didout |= sst->save_msg_didout; // don't reset msg_didout now
|
msg_didout |= sst->save_msg_didout; // don't reset msg_didout now
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
current_sctx.sc_version = sst->save_script_version;
|
current_sctx.sc_version = sst->save_script_version;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Restore the state (needed when called from a function executed for
|
// Restore the state (needed when called from a function executed for
|
||||||
// 'indentexpr'). Update the mouse and cursor, they may have changed.
|
// 'indentexpr'). Update the mouse and cursor, they may have changed.
|
||||||
|
@ -290,6 +290,14 @@ EXTERN garray_T exestack INIT5(0, 0, sizeof(estack_T), 50, NULL);
|
|||||||
// line number in the message source or zero
|
// line number in the message source or zero
|
||||||
#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum)
|
#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum)
|
||||||
|
|
||||||
|
// Script CTX being sourced or was sourced to define the current function.
|
||||||
|
EXTERN sctx_T current_sctx
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
INIT4(0, 0, 0, 0);
|
||||||
|
#else
|
||||||
|
INIT(= {0});
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
// whether inside compile_def_function()
|
// whether inside compile_def_function()
|
||||||
EXTERN int estack_compiling INIT(= FALSE);
|
EXTERN int estack_compiling INIT(= FALSE);
|
||||||
@ -392,9 +400,6 @@ EXTERN int may_garbage_collect INIT(= FALSE);
|
|||||||
EXTERN int want_garbage_collect INIT(= FALSE);
|
EXTERN int want_garbage_collect INIT(= FALSE);
|
||||||
EXTERN int garbage_collect_at_exit INIT(= FALSE);
|
EXTERN int garbage_collect_at_exit INIT(= FALSE);
|
||||||
|
|
||||||
// Script CTX being sourced or was sourced to define the current function.
|
|
||||||
EXTERN sctx_T current_sctx INIT4(0, 0, 0, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// Commonly used types.
|
// Commonly used types.
|
||||||
EXTERN type_T t_unknown INIT6(VAR_UNKNOWN, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
EXTERN type_T t_unknown INIT6(VAR_UNKNOWN, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
||||||
|
10
src/main.c
10
src/main.c
@ -3269,9 +3269,8 @@ process_env(
|
|||||||
int is_viminit) // when TRUE, called for VIMINIT
|
int is_viminit) // when TRUE, called for VIMINIT
|
||||||
{
|
{
|
||||||
char_u *initstr;
|
char_u *initstr;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sctx_T save_current_sctx;
|
sctx_T save_current_sctx;
|
||||||
#endif
|
|
||||||
ESTACK_CHECK_DECLARATION
|
ESTACK_CHECK_DECLARATION
|
||||||
|
|
||||||
if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL)
|
if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL)
|
||||||
@ -3280,20 +3279,19 @@ process_env(
|
|||||||
vimrc_found(NULL, NULL);
|
vimrc_found(NULL, NULL);
|
||||||
estack_push(ETYPE_ENV, env, 0);
|
estack_push(ETYPE_ENV, env, 0);
|
||||||
ESTACK_CHECK_SETUP
|
ESTACK_CHECK_SETUP
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
save_current_sctx = current_sctx;
|
save_current_sctx = current_sctx;
|
||||||
|
current_sctx.sc_version = 1;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
current_sctx.sc_sid = SID_ENV;
|
current_sctx.sc_sid = SID_ENV;
|
||||||
current_sctx.sc_seq = 0;
|
current_sctx.sc_seq = 0;
|
||||||
current_sctx.sc_lnum = 0;
|
current_sctx.sc_lnum = 0;
|
||||||
current_sctx.sc_version = 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_cmdline_cmd(initstr);
|
do_cmdline_cmd(initstr);
|
||||||
|
|
||||||
ESTACK_CHECK_NOW
|
ESTACK_CHECK_NOW
|
||||||
estack_pop();
|
estack_pop();
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
#endif
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
12
src/menu.c
12
src/menu.c
@ -2310,11 +2310,7 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
|
|||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
// Use the Insert mode entry when returning to Insert mode.
|
// Use the Insert mode entry when returning to Insert mode.
|
||||||
if (restart_edit
|
if (restart_edit && !current_sctx.sc_sid)
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
&& !current_sctx.sc_sid
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
idx = MENU_INDEX_INSERT;
|
idx = MENU_INDEX_INSERT;
|
||||||
}
|
}
|
||||||
@ -2384,11 +2380,7 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
|
|||||||
// When executing a script or function execute the commands right now.
|
// When executing a script or function execute the commands right now.
|
||||||
// Also for the window toolbar.
|
// Also for the window toolbar.
|
||||||
// Otherwise put them in the typeahead buffer.
|
// Otherwise put them in the typeahead buffer.
|
||||||
if (eap == NULL
|
if (eap == NULL || current_sctx.sc_sid != 0)
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
|| current_sctx.sc_sid != 0
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
save_state_T save_state;
|
save_state_T save_state;
|
||||||
|
|
||||||
|
@ -233,10 +233,10 @@ void mbyte_im_set_active(int active_arg);
|
|||||||
# include "usercmd.pro"
|
# include "usercmd.pro"
|
||||||
# include "userfunc.pro"
|
# include "userfunc.pro"
|
||||||
# include "version.pro"
|
# include "version.pro"
|
||||||
|
# include "vim9script.pro"
|
||||||
# ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
# include "vim9compile.pro"
|
# include "vim9compile.pro"
|
||||||
# include "vim9execute.pro"
|
# include "vim9execute.pro"
|
||||||
# include "vim9script.pro"
|
|
||||||
# include "vim9type.pro"
|
# include "vim9type.pro"
|
||||||
# endif
|
# endif
|
||||||
# include "window.pro"
|
# include "window.pro"
|
||||||
|
@ -1135,8 +1135,8 @@ do_source(
|
|||||||
char_u *fname_exp;
|
char_u *fname_exp;
|
||||||
char_u *firstline = NULL;
|
char_u *firstline = NULL;
|
||||||
int retval = FAIL;
|
int retval = FAIL;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sctx_T save_current_sctx;
|
sctx_T save_current_sctx;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
static scid_T last_current_SID = 0;
|
static scid_T last_current_SID = 0;
|
||||||
static int last_current_SID_seq = 0;
|
static int last_current_SID_seq = 0;
|
||||||
funccal_entry_T funccalp_entry;
|
funccal_entry_T funccalp_entry;
|
||||||
@ -1300,6 +1300,9 @@ do_source(
|
|||||||
time_push(&tv_rel, &tv_start);
|
time_push(&tv_rel, &tv_start);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
save_current_sctx = current_sctx;
|
||||||
|
current_sctx.sc_version = 1; // default script version
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
# ifdef FEAT_PROFILE
|
# ifdef FEAT_PROFILE
|
||||||
if (do_profiling == PROF_YES)
|
if (do_profiling == PROF_YES)
|
||||||
@ -1310,9 +1313,7 @@ do_source(
|
|||||||
// Also starts profiling timer for nested script.
|
// Also starts profiling timer for nested script.
|
||||||
save_funccal(&funccalp_entry);
|
save_funccal(&funccalp_entry);
|
||||||
|
|
||||||
save_current_sctx = current_sctx;
|
|
||||||
current_sctx.sc_lnum = 0;
|
current_sctx.sc_lnum = 0;
|
||||||
current_sctx.sc_version = 1; // default script version
|
|
||||||
|
|
||||||
// Check if this script was sourced before to finds its SID.
|
// Check if this script was sourced before to finds its SID.
|
||||||
// Always use a new sequence number.
|
// Always use a new sequence number.
|
||||||
@ -1326,7 +1327,6 @@ do_source(
|
|||||||
|
|
||||||
// loading the same script again
|
// loading the same script again
|
||||||
si->sn_state = SN_STATE_RELOAD;
|
si->sn_state = SN_STATE_RELOAD;
|
||||||
si->sn_version = 1;
|
|
||||||
current_sctx.sc_sid = sid;
|
current_sctx.sc_sid = sid;
|
||||||
|
|
||||||
// Script-local variables remain but "const" can be set again.
|
// Script-local variables remain but "const" can be set again.
|
||||||
@ -1484,13 +1484,14 @@ almosttheend:
|
|||||||
CLEAR_POINTER(si->sn_save_cpo);
|
CLEAR_POINTER(si->sn_save_cpo);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_sctx = save_current_sctx;
|
|
||||||
restore_funccal();
|
restore_funccal();
|
||||||
# ifdef FEAT_PROFILE
|
# ifdef FEAT_PROFILE
|
||||||
if (do_profiling == PROF_YES)
|
if (do_profiling == PROF_YES)
|
||||||
prof_child_exit(&wait_start); // leaving a child now
|
prof_child_exit(&wait_start); // leaving a child now
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
current_sctx = save_current_sctx;
|
||||||
|
|
||||||
fclose(cookie.fp);
|
fclose(cookie.fp);
|
||||||
vim_free(cookie.nextline);
|
vim_free(cookie.nextline);
|
||||||
vim_free(firstline);
|
vim_free(firstline);
|
||||||
@ -1903,7 +1904,6 @@ ex_scriptencoding(exarg_T *eap)
|
|||||||
void
|
void
|
||||||
ex_scriptversion(exarg_T *eap UNUSED)
|
ex_scriptversion(exarg_T *eap UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
int nr;
|
int nr;
|
||||||
|
|
||||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
|
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
|
||||||
@ -1925,10 +1925,11 @@ ex_scriptversion(exarg_T *eap UNUSED)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
current_sctx.sc_version = nr;
|
current_sctx.sc_version = nr;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
SCRIPT_ITEM(current_sctx.sc_sid)->sn_version = nr;
|
SCRIPT_ITEM(current_sctx.sc_sid)->sn_version = nr;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
/*
|
/*
|
||||||
|
@ -83,9 +83,11 @@ typedef struct VimMenu vimmenu_T;
|
|||||||
* sc_version is also here, for convenience.
|
* sc_version is also here, for convenience.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
scid_T sc_sid; // script ID
|
scid_T sc_sid; // script ID
|
||||||
int sc_seq; // sourcing sequence number
|
int sc_seq; // sourcing sequence number
|
||||||
linenr_T sc_lnum; // line number
|
linenr_T sc_lnum; // line number
|
||||||
|
#endif
|
||||||
int sc_version; // :scriptversion
|
int sc_version; // :scriptversion
|
||||||
} sctx_T;
|
} sctx_T;
|
||||||
|
|
||||||
@ -1224,8 +1226,8 @@ struct mapblock
|
|||||||
char m_silent; // <silent> used, don't echo commands
|
char m_silent; // <silent> used, don't echo commands
|
||||||
char m_nowait; // <nowait> used
|
char m_nowait; // <nowait> used
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
char m_expr; // <expr> used, m_str is an expression
|
|
||||||
sctx_T m_script_ctx; // SCTX where map was defined
|
sctx_T m_script_ctx; // SCTX where map was defined
|
||||||
|
char m_expr; // <expr> used, m_str is an expression
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1567,6 +1569,8 @@ typedef enum {
|
|||||||
GETLINE_CONCAT_ALL // concatenate continuation and Vim9 # comment lines
|
GETLINE_CONCAT_ALL // concatenate continuation and Vim9 # comment lines
|
||||||
} getline_opt_T;
|
} getline_opt_T;
|
||||||
|
|
||||||
|
typedef struct svar_S svar_T;
|
||||||
|
|
||||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
typedef struct funccall_S funccall_T;
|
typedef struct funccall_S funccall_T;
|
||||||
|
|
||||||
@ -1766,13 +1770,13 @@ struct sallvar_S {
|
|||||||
/*
|
/*
|
||||||
* Entry for "sn_var_vals". Used for script-local variables.
|
* Entry for "sn_var_vals". Used for script-local variables.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
struct svar_S {
|
||||||
char_u *sv_name; // points into "sn_all_vars" di_key
|
char_u *sv_name; // points into "sn_all_vars" di_key
|
||||||
typval_T *sv_tv; // points into "sn_vars" or "sn_all_vars" di_tv
|
typval_T *sv_tv; // points into "sn_vars" or "sn_all_vars" di_tv
|
||||||
type_T *sv_type;
|
type_T *sv_type;
|
||||||
int sv_const;
|
int sv_const;
|
||||||
int sv_export; // "export let var = val"
|
int sv_export; // "export let var = val"
|
||||||
} svar_T;
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char_u *imp_name; // name imported as (allocated)
|
char_u *imp_name; // name imported as (allocated)
|
||||||
@ -4164,9 +4168,7 @@ typedef struct {
|
|||||||
int save_finish_op;
|
int save_finish_op;
|
||||||
int save_opcount;
|
int save_opcount;
|
||||||
int save_reg_executing;
|
int save_reg_executing;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
int save_script_version;
|
int save_script_version;
|
||||||
#endif
|
|
||||||
tasave_T tabuf;
|
tasave_T tabuf;
|
||||||
} save_state_T;
|
} save_state_T;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ typedef struct ucmd
|
|||||||
long uc_def; // The default value for a range/count
|
long uc_def; // The default value for a range/count
|
||||||
int uc_compl; // completion type
|
int uc_compl; // completion type
|
||||||
cmd_addr_T uc_addr_type; // The command's address type
|
cmd_addr_T uc_addr_type; // The command's address type
|
||||||
# ifdef FEAT_EVAL
|
|
||||||
sctx_T uc_script_ctx; // SCTX where the command was defined
|
sctx_T uc_script_ctx; // SCTX where the command was defined
|
||||||
|
# ifdef FEAT_EVAL
|
||||||
char_u *uc_compl_arg; // completion argument if any
|
char_u *uc_compl_arg; // completion argument if any
|
||||||
# endif
|
# endif
|
||||||
} ucmd_T;
|
} ucmd_T;
|
||||||
@ -954,8 +954,8 @@ uc_add_command(
|
|||||||
cmd->uc_argt = argt;
|
cmd->uc_argt = argt;
|
||||||
cmd->uc_def = def;
|
cmd->uc_def = def;
|
||||||
cmd->uc_compl = compl;
|
cmd->uc_compl = compl;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
cmd->uc_script_ctx = current_sctx;
|
cmd->uc_script_ctx = current_sctx;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
cmd->uc_script_ctx.sc_lnum += SOURCING_LNUM;
|
cmd->uc_script_ctx.sc_lnum += SOURCING_LNUM;
|
||||||
cmd->uc_compl_arg = compl_arg;
|
cmd->uc_compl_arg = compl_arg;
|
||||||
#endif
|
#endif
|
||||||
@ -1573,9 +1573,7 @@ do_ucmd(exarg_T *eap)
|
|||||||
size_t split_len = 0;
|
size_t split_len = 0;
|
||||||
char_u *split_buf = NULL;
|
char_u *split_buf = NULL;
|
||||||
ucmd_T *cmd;
|
ucmd_T *cmd;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
sctx_T save_current_sctx = current_sctx;
|
sctx_T save_current_sctx = current_sctx;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (eap->cmdidx == CMD_USER)
|
if (eap->cmdidx == CMD_USER)
|
||||||
cmd = USER_CMD(eap->useridx);
|
cmd = USER_CMD(eap->useridx);
|
||||||
@ -1674,15 +1672,13 @@ do_ucmd(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_sctx.sc_version = cmd->uc_script_ctx.sc_version;
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
current_sctx.sc_sid = cmd->uc_script_ctx.sc_sid;
|
current_sctx.sc_sid = cmd->uc_script_ctx.sc_sid;
|
||||||
current_sctx.sc_version = cmd->uc_script_ctx.sc_version;
|
|
||||||
#endif
|
#endif
|
||||||
(void)do_cmdline(buf, eap->getline, eap->cookie,
|
(void)do_cmdline(buf, eap->getline, eap->cookie,
|
||||||
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
|
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
#endif
|
|
||||||
vim_free(buf);
|
vim_free(buf);
|
||||||
vim_free(split_buf);
|
vim_free(split_buf);
|
||||||
}
|
}
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2238,
|
||||||
/**/
|
/**/
|
||||||
2237,
|
2237,
|
||||||
/**/
|
/**/
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
#include "vim.h"
|
#include "vim.h"
|
||||||
|
|
||||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
#if defined(FEAT_EVAL)
|
||||||
|
|
||||||
# include "vim9.h"
|
# include "vim9.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
in_vim9script(void)
|
in_vim9script(void)
|
||||||
@ -30,8 +30,9 @@ in_vim9script(void)
|
|||||||
* ":vim9script".
|
* ":vim9script".
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ex_vim9script(exarg_T *eap)
|
ex_vim9script(exarg_T *eap UNUSED)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
int sid = current_sctx.sc_sid;
|
int sid = current_sctx.sc_sid;
|
||||||
scriptitem_T *si;
|
scriptitem_T *si;
|
||||||
|
|
||||||
@ -75,6 +76,10 @@ ex_vim9script(exarg_T *eap)
|
|||||||
si->sn_save_cpo = vim_strsave(p_cpo);
|
si->sn_save_cpo = vim_strsave(p_cpo);
|
||||||
set_option_value((char_u *)"cpo", 0L, (char_u *)CPO_VIM, 0);
|
set_option_value((char_u *)"cpo", 0L, (char_u *)CPO_VIM, 0);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// No check for this being the first command, it doesn't matter.
|
||||||
|
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -91,13 +96,15 @@ not_in_vim9(exarg_T *eap)
|
|||||||
case CMD_insert:
|
case CMD_insert:
|
||||||
case CMD_t:
|
case CMD_t:
|
||||||
case CMD_xit:
|
case CMD_xit:
|
||||||
semsg(_(e_missing_var_str), eap->cmd);
|
semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":export let Name: type"
|
* ":export let Name: type"
|
||||||
* ":export const Name: type"
|
* ":export const Name: type"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user