Mercurial > vim
comparison src/scriptfile.c @ 23390:9a5f12b36273 v8.2.2238
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Commit: https://github.com/vim/vim/commit/9b8d62267f583d5dc042920adb1de046959ad11d
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 28 18:26:00 2020 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 28 Dec 2020 18:30:03 +0100 |
parents | 3105546b941f |
children | 517fca70e084 |
comparison
equal
deleted
inserted
replaced
23389:f67d856ae24e | 23390:9a5f12b36273 |
---|---|
1133 struct source_cookie cookie; | 1133 struct source_cookie cookie; |
1134 char_u *p; | 1134 char_u *p; |
1135 char_u *fname_exp; | 1135 char_u *fname_exp; |
1136 char_u *firstline = NULL; | 1136 char_u *firstline = NULL; |
1137 int retval = FAIL; | 1137 int retval = FAIL; |
1138 sctx_T save_current_sctx; | |
1138 #ifdef FEAT_EVAL | 1139 #ifdef FEAT_EVAL |
1139 sctx_T save_current_sctx; | |
1140 static scid_T last_current_SID = 0; | 1140 static scid_T last_current_SID = 0; |
1141 static int last_current_SID_seq = 0; | 1141 static int last_current_SID_seq = 0; |
1142 funccal_entry_T funccalp_entry; | 1142 funccal_entry_T funccalp_entry; |
1143 int save_debug_break_level = debug_break_level; | 1143 int save_debug_break_level = debug_break_level; |
1144 int sid; | 1144 int sid; |
1298 #ifdef STARTUPTIME | 1298 #ifdef STARTUPTIME |
1299 if (time_fd != NULL) | 1299 if (time_fd != NULL) |
1300 time_push(&tv_rel, &tv_start); | 1300 time_push(&tv_rel, &tv_start); |
1301 #endif | 1301 #endif |
1302 | 1302 |
1303 save_current_sctx = current_sctx; | |
1304 current_sctx.sc_version = 1; // default script version | |
1305 | |
1303 #ifdef FEAT_EVAL | 1306 #ifdef FEAT_EVAL |
1304 # ifdef FEAT_PROFILE | 1307 # ifdef FEAT_PROFILE |
1305 if (do_profiling == PROF_YES) | 1308 if (do_profiling == PROF_YES) |
1306 prof_child_enter(&wait_start); // entering a child now | 1309 prof_child_enter(&wait_start); // entering a child now |
1307 # endif | 1310 # endif |
1308 | 1311 |
1309 // Don't use local function variables, if called from a function. | 1312 // Don't use local function variables, if called from a function. |
1310 // Also starts profiling timer for nested script. | 1313 // Also starts profiling timer for nested script. |
1311 save_funccal(&funccalp_entry); | 1314 save_funccal(&funccalp_entry); |
1312 | 1315 |
1313 save_current_sctx = current_sctx; | |
1314 current_sctx.sc_lnum = 0; | 1316 current_sctx.sc_lnum = 0; |
1315 current_sctx.sc_version = 1; // default script version | |
1316 | 1317 |
1317 // Check if this script was sourced before to finds its SID. | 1318 // Check if this script was sourced before to finds its SID. |
1318 // Always use a new sequence number. | 1319 // Always use a new sequence number. |
1319 current_sctx.sc_seq = ++last_current_SID_seq; | 1320 current_sctx.sc_seq = ++last_current_SID_seq; |
1320 if (sid > 0) | 1321 if (sid > 0) |
1324 hashitem_T *hi; | 1325 hashitem_T *hi; |
1325 dictitem_T *di; | 1326 dictitem_T *di; |
1326 | 1327 |
1327 // loading the same script again | 1328 // loading the same script again |
1328 si->sn_state = SN_STATE_RELOAD; | 1329 si->sn_state = SN_STATE_RELOAD; |
1329 si->sn_version = 1; | |
1330 current_sctx.sc_sid = sid; | 1330 current_sctx.sc_sid = sid; |
1331 | 1331 |
1332 // Script-local variables remain but "const" can be set again. | 1332 // Script-local variables remain but "const" can be set again. |
1333 // In Vim9 script variables will be cleared when "vim9script" is | 1333 // In Vim9 script variables will be cleared when "vim9script" is |
1334 // encountered without the "noclear" argument. | 1334 // encountered without the "noclear" argument. |
1482 { | 1482 { |
1483 set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0); | 1483 set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0); |
1484 CLEAR_POINTER(si->sn_save_cpo); | 1484 CLEAR_POINTER(si->sn_save_cpo); |
1485 } | 1485 } |
1486 | 1486 |
1487 current_sctx = save_current_sctx; | |
1488 restore_funccal(); | 1487 restore_funccal(); |
1489 # ifdef FEAT_PROFILE | 1488 # ifdef FEAT_PROFILE |
1490 if (do_profiling == PROF_YES) | 1489 if (do_profiling == PROF_YES) |
1491 prof_child_exit(&wait_start); // leaving a child now | 1490 prof_child_exit(&wait_start); // leaving a child now |
1492 # endif | 1491 # endif |
1493 #endif | 1492 #endif |
1493 current_sctx = save_current_sctx; | |
1494 | |
1494 fclose(cookie.fp); | 1495 fclose(cookie.fp); |
1495 vim_free(cookie.nextline); | 1496 vim_free(cookie.nextline); |
1496 vim_free(firstline); | 1497 vim_free(firstline); |
1497 convert_setup(&cookie.conv, NULL, NULL); | 1498 convert_setup(&cookie.conv, NULL, NULL); |
1498 | 1499 |
1901 * ":scriptversion": Set Vim script version for a sourced script. | 1902 * ":scriptversion": Set Vim script version for a sourced script. |
1902 */ | 1903 */ |
1903 void | 1904 void |
1904 ex_scriptversion(exarg_T *eap UNUSED) | 1905 ex_scriptversion(exarg_T *eap UNUSED) |
1905 { | 1906 { |
1906 #ifdef FEAT_EVAL | |
1907 int nr; | 1907 int nr; |
1908 | 1908 |
1909 if (!getline_equal(eap->getline, eap->cookie, getsourceline)) | 1909 if (!getline_equal(eap->getline, eap->cookie, getsourceline)) |
1910 { | 1910 { |
1911 emsg(_("E984: :scriptversion used outside of a sourced file")); | 1911 emsg(_("E984: :scriptversion used outside of a sourced file")); |
1923 else if (nr > SCRIPT_VERSION_MAX) | 1923 else if (nr > SCRIPT_VERSION_MAX) |
1924 semsg(_("E999: scriptversion not supported: %d"), nr); | 1924 semsg(_("E999: scriptversion not supported: %d"), nr); |
1925 else | 1925 else |
1926 { | 1926 { |
1927 current_sctx.sc_version = nr; | 1927 current_sctx.sc_version = nr; |
1928 #ifdef FEAT_EVAL | |
1928 SCRIPT_ITEM(current_sctx.sc_sid)->sn_version = nr; | 1929 SCRIPT_ITEM(current_sctx.sc_sid)->sn_version = nr; |
1929 } | 1930 #endif |
1930 #endif | 1931 } |
1931 } | 1932 } |
1932 | 1933 |
1933 #if defined(FEAT_EVAL) || defined(PROTO) | 1934 #if defined(FEAT_EVAL) || defined(PROTO) |
1934 /* | 1935 /* |
1935 * ":finish": Mark a sourced file as finished. | 1936 * ":finish": Mark a sourced file as finished. |