Mercurial > vim
comparison src/structs.h @ 19181:94eda51ba9ba v8.2.0149
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Commit: https://github.com/vim/vim/commit/8a7d6542b33e5d2b352262305c3bfdb2d14e1cf8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 26 15:56:19 2020 +0100
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Problem: Maintaining a Vim9 branch separately is more work.
Solution: Merge the Vim9 script changes.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Jan 2020 16:00:05 +0100 |
parents | 44c6498535c9 |
children | 17d878a2ddaa |
comparison
equal
deleted
inserted
replaced
19180:8edf0aeb71b9 | 19181:94eda51ba9ba |
---|---|
64 typedef struct terminal_S term_T; | 64 typedef struct terminal_S term_T; |
65 | 65 |
66 #ifdef FEAT_MENU | 66 #ifdef FEAT_MENU |
67 typedef struct VimMenu vimmenu_T; | 67 typedef struct VimMenu vimmenu_T; |
68 #endif | 68 #endif |
69 | |
70 // value for sc_version in a Vim9 script file | |
71 #define SCRIPT_VERSION_VIM9 999999 | |
69 | 72 |
70 /* | 73 /* |
71 * SCript ConteXt (SCTX): identifies a script line. | 74 * SCript ConteXt (SCTX): identifies a script line. |
72 * When sourcing a script "sc_lnum" is zero, "sourcing_lnum" is the current | 75 * When sourcing a script "sc_lnum" is zero, "sourcing_lnum" is the current |
73 * line number. When executing a user function "sc_lnum" is the line where the | 76 * line number. When executing a user function "sc_lnum" is the line where the |
1296 char_u *cb_name; | 1299 char_u *cb_name; |
1297 partial_T *cb_partial; | 1300 partial_T *cb_partial; |
1298 int cb_free_name; // cb_name was allocated | 1301 int cb_free_name; // cb_name was allocated |
1299 } callback_T; | 1302 } callback_T; |
1300 | 1303 |
1304 typedef struct dfunc_S dfunc_T; // :def function | |
1305 | |
1301 typedef struct jobvar_S job_T; | 1306 typedef struct jobvar_S job_T; |
1302 typedef struct readq_S readq_T; | 1307 typedef struct readq_S readq_T; |
1303 typedef struct writeq_S writeq_T; | 1308 typedef struct writeq_S writeq_T; |
1304 typedef struct jsonq_S jsonq_T; | 1309 typedef struct jsonq_S jsonq_T; |
1305 typedef struct cbq_S cbq_T; | 1310 typedef struct cbq_S cbq_T; |
1306 typedef struct channel_S channel_T; | 1311 typedef struct channel_S channel_T; |
1312 typedef struct cctx_S cctx_T; | |
1307 | 1313 |
1308 typedef enum | 1314 typedef enum |
1309 { | 1315 { |
1310 VAR_UNKNOWN = 0, | 1316 VAR_UNKNOWN = 0, // not set, also used for "any" type |
1311 VAR_NUMBER, // "v_number" is used | 1317 VAR_VOID, // no value |
1312 VAR_STRING, // "v_string" is used | 1318 VAR_BOOL, // "v_number" is used: VVAL_TRUE or VVAL_FALSE |
1313 VAR_FUNC, // "v_string" is function name | 1319 VAR_SPECIAL, // "v_number" is used: VVAL_NULL or VVAL_NONE |
1314 VAR_PARTIAL, // "v_partial" is used | 1320 VAR_NUMBER, // "v_number" is used |
1315 VAR_LIST, // "v_list" is used | 1321 VAR_FLOAT, // "v_float" is used |
1316 VAR_DICT, // "v_dict" is used | 1322 VAR_STRING, // "v_string" is used |
1317 VAR_FLOAT, // "v_float" is used | 1323 VAR_BLOB, // "v_blob" is used |
1318 VAR_BOOL, // "v_number" is VVAL_FALSE or VVAL_TRUE | 1324 VAR_FUNC, // "v_string" is function name |
1319 VAR_SPECIAL, // "v_number" is VVAL_NONE or VVAL_NULL | 1325 VAR_PARTIAL, // "v_partial" is used |
1320 VAR_JOB, // "v_job" is used | 1326 VAR_LIST, // "v_list" is used |
1321 VAR_CHANNEL, // "v_channel" is used | 1327 VAR_DICT, // "v_dict" is used |
1322 VAR_BLOB, // "v_blob" is used | 1328 VAR_JOB, // "v_job" is used |
1329 VAR_CHANNEL, // "v_channel" is used | |
1323 } vartype_T; | 1330 } vartype_T; |
1331 | |
1332 // A type specification. | |
1333 typedef struct type_S type_T; | |
1334 struct type_S { | |
1335 vartype_T tt_type; | |
1336 short tt_argcount; // for func, partial, -1 for unknown | |
1337 type_T *tt_member; // for list, dict, func return type | |
1338 type_T *tt_args; // func arguments | |
1339 }; | |
1324 | 1340 |
1325 /* | 1341 /* |
1326 * Structure to hold an internal variable without a name. | 1342 * Structure to hold an internal variable without a name. |
1327 */ | 1343 */ |
1328 typedef struct | 1344 typedef struct |
1378 }; | 1394 }; |
1379 | 1395 |
1380 /* | 1396 /* |
1381 * Structure to hold info about a list. | 1397 * Structure to hold info about a list. |
1382 * Order of members is optimized to reduce padding. | 1398 * Order of members is optimized to reduce padding. |
1399 * When created by range() it will at first have special value: | |
1400 * lv_first == &range_list_item; | |
1401 * and use lv_start, lv_end, lv_stride. | |
1383 */ | 1402 */ |
1384 struct listvar_S | 1403 struct listvar_S |
1385 { | 1404 { |
1386 listitem_T *lv_first; // first item, NULL if none | 1405 listitem_T *lv_first; // first item, NULL if none |
1387 listitem_T *lv_last; // last item, NULL if none | |
1388 listwatch_T *lv_watch; // first watcher, NULL if none | 1406 listwatch_T *lv_watch; // first watcher, NULL if none |
1389 listitem_T *lv_idx_item; // when not NULL item at index "lv_idx" | 1407 union { |
1408 struct { // used for non-materialized range list: | |
1409 // "lv_first" is &range_list_item | |
1410 varnumber_T lv_start; | |
1411 varnumber_T lv_end; | |
1412 int lv_stride; | |
1413 }; | |
1414 struct { // used for materialized list | |
1415 listitem_T *lv_last; // last item, NULL if none | |
1416 listitem_T *lv_idx_item; // when not NULL item at index "lv_idx" | |
1417 int lv_idx; // cached index of an item | |
1418 }; | |
1419 }; | |
1390 list_T *lv_copylist; // copied list used by deepcopy() | 1420 list_T *lv_copylist; // copied list used by deepcopy() |
1391 list_T *lv_used_next; // next list in used lists list | 1421 list_T *lv_used_next; // next list in used lists list |
1392 list_T *lv_used_prev; // previous list in used lists list | 1422 list_T *lv_used_prev; // previous list in used lists list |
1393 int lv_refcount; // reference count | 1423 int lv_refcount; // reference count |
1394 int lv_len; // number of items | 1424 int lv_len; // number of items |
1395 int lv_idx; // cached index of an item | 1425 int lv_with_items; // number of items following this struct that |
1426 // should not be freed | |
1396 int lv_copyID; // ID used by deepcopy() | 1427 int lv_copyID; // ID used by deepcopy() |
1397 char lv_lock; // zero, VAR_LOCKED, VAR_FIXED | 1428 char lv_lock; // zero, VAR_LOCKED, VAR_FIXED |
1398 }; | 1429 }; |
1399 | 1430 |
1400 /* | 1431 /* |
1411 * The key is copied into "di_key" to avoid an extra alloc/free for it. | 1442 * The key is copied into "di_key" to avoid an extra alloc/free for it. |
1412 */ | 1443 */ |
1413 struct dictitem_S | 1444 struct dictitem_S |
1414 { | 1445 { |
1415 typval_T di_tv; // type and value of the variable | 1446 typval_T di_tv; // type and value of the variable |
1416 char_u di_flags; // flags (only used for variable) | 1447 char_u di_flags; // DI_FLAGS_ flags (only used for variable) |
1417 char_u di_key[1]; // key (actually longer!) | 1448 char_u di_key[1]; // key (actually longer!) |
1418 }; | 1449 }; |
1419 typedef struct dictitem_S dictitem_T; | 1450 typedef struct dictitem_S dictitem_T; |
1420 | 1451 |
1421 /* | 1452 /* |
1424 */ | 1455 */ |
1425 #define DICTITEM16_KEY_LEN 16 | 1456 #define DICTITEM16_KEY_LEN 16 |
1426 struct dictitem16_S | 1457 struct dictitem16_S |
1427 { | 1458 { |
1428 typval_T di_tv; // type and value of the variable | 1459 typval_T di_tv; // type and value of the variable |
1429 char_u di_flags; // flags (only used for variable) | 1460 char_u di_flags; // DI_FLAGS_ flags (only used for variable) |
1430 char_u di_key[DICTITEM16_KEY_LEN + 1]; // key | 1461 char_u di_key[DICTITEM16_KEY_LEN + 1]; // key |
1431 }; | 1462 }; |
1432 typedef struct dictitem16_S dictitem16_T; | 1463 typedef struct dictitem16_S dictitem16_T; |
1433 | 1464 |
1434 #define DI_FLAGS_RO 1 // "di_flags" value: read-only variable | 1465 // Flags for "di_flags" |
1435 #define DI_FLAGS_RO_SBX 2 // "di_flags" value: read-only in the sandbox | 1466 #define DI_FLAGS_RO 0x01 // read-only variable |
1436 #define DI_FLAGS_FIX 4 // "di_flags" value: fixed: no :unlet or remove() | 1467 #define DI_FLAGS_RO_SBX 0x02 // read-only in the sandbox |
1437 #define DI_FLAGS_LOCK 8 // "di_flags" value: locked variable | 1468 #define DI_FLAGS_FIX 0x04 // fixed: no :unlet or remove() |
1438 #define DI_FLAGS_ALLOC 16 // "di_flags" value: separately allocated | 1469 #define DI_FLAGS_LOCK 0x08 // locked variable |
1470 #define DI_FLAGS_ALLOC 0x10 // separately allocated | |
1471 #define DI_FLAGS_RELOAD 0x20 // set when script sourced again | |
1439 | 1472 |
1440 /* | 1473 /* |
1441 * Structure to hold info about a Dictionary. | 1474 * Structure to hold info about a Dictionary. |
1442 */ | 1475 */ |
1443 struct dictvar_S | 1476 struct dictvar_S |
1468 /* | 1501 /* |
1469 * Structure to hold info for a user function. | 1502 * Structure to hold info for a user function. |
1470 */ | 1503 */ |
1471 typedef struct | 1504 typedef struct |
1472 { | 1505 { |
1473 int uf_varargs; // variable nr of arguments | 1506 int uf_varargs; // variable nr of arguments (old style) |
1474 int uf_flags; | 1507 int uf_flags; // FC_ flags |
1475 int uf_calls; // nr of active calls | 1508 int uf_calls; // nr of active calls |
1476 int uf_cleared; // func_clear() was already called | 1509 int uf_cleared; // func_clear() was already called |
1510 int uf_dfunc_idx; // >= 0 for :def function only | |
1477 garray_T uf_args; // arguments | 1511 garray_T uf_args; // arguments |
1478 garray_T uf_def_args; // default argument expressions | 1512 garray_T uf_def_args; // default argument expressions |
1513 | |
1514 // for :def (for :function uf_ret_type is NULL) | |
1515 type_T **uf_arg_types; // argument types (count == uf_args.ga_len) | |
1516 type_T *uf_ret_type; // return type | |
1517 garray_T uf_type_list; // types used in arg and return types | |
1518 char_u *uf_va_name; // name from "...name" or NULL | |
1519 type_T *uf_va_type; // type from "...name: type" or NULL | |
1520 | |
1479 garray_T uf_lines; // function lines | 1521 garray_T uf_lines; // function lines |
1480 # ifdef FEAT_PROFILE | 1522 # ifdef FEAT_PROFILE |
1481 int uf_profiling; // TRUE when func is being profiled | 1523 int uf_profiling; // TRUE when func is being profiled |
1482 int uf_prof_initialized; | 1524 int uf_prof_initialized; |
1483 // profiling the function as a whole | 1525 // profiling the function as a whole |
1576 dictitem_T sv_var; | 1618 dictitem_T sv_var; |
1577 dict_T sv_dict; | 1619 dict_T sv_dict; |
1578 } scriptvar_T; | 1620 } scriptvar_T; |
1579 | 1621 |
1580 /* | 1622 /* |
1623 * Entry for "sn_var_vals". Used for script-local variables. | |
1624 */ | |
1625 typedef struct { | |
1626 char_u *sv_name; // points into "sn_vars" di_key | |
1627 typval_T *sv_tv; // points into "sn_vars" di_tv | |
1628 type_T *sv_type; | |
1629 int sv_const; | |
1630 int sv_export; // "export let var = val" | |
1631 } svar_T; | |
1632 | |
1633 typedef struct { | |
1634 char_u *imp_name; // name imported as (allocated) | |
1635 int imp_sid; // script ID of "from" | |
1636 | |
1637 // for "import * as Name", "imp_name" is "Name" | |
1638 int imp_all; | |
1639 | |
1640 // for variable | |
1641 type_T *imp_type; | |
1642 int imp_var_vals_idx; // index in sn_var_vals of "from" | |
1643 | |
1644 // for function | |
1645 char_u *imp_funcname; // user func name (NOT allocated) | |
1646 } imported_T; | |
1647 | |
1648 /* | |
1581 * Growarray to store info about already sourced scripts. | 1649 * Growarray to store info about already sourced scripts. |
1582 * For Unix also store the dev/ino, so that we don't have to stat() each | 1650 * For Unix also store the dev/ino, so that we don't have to stat() each |
1583 * script when going through the list. | 1651 * script when going through the list. |
1584 */ | 1652 */ |
1585 typedef struct | 1653 typedef struct |
1586 { | 1654 { |
1655 char_u *sn_name; | |
1656 | |
1587 scriptvar_T *sn_vars; // stores s: variables for this script | 1657 scriptvar_T *sn_vars; // stores s: variables for this script |
1588 | 1658 garray_T sn_var_vals; // same variables as a list of svar_T |
1589 char_u *sn_name; | 1659 |
1660 garray_T sn_imports; // imported items, imported_T | |
1661 | |
1662 garray_T sn_type_list; // keeps types used by variables | |
1590 | 1663 |
1591 int sn_version; // :scriptversion | 1664 int sn_version; // :scriptversion |
1665 int sn_had_command; // TRUE if any command was executed | |
1666 char_u *sn_save_cpo; // 'cpo' value when :vim9script found | |
1592 | 1667 |
1593 # ifdef UNIX | 1668 # ifdef UNIX |
1594 int sn_dev_valid; | 1669 int sn_dev_valid; |
1595 dev_t sn_dev; | 1670 dev_t sn_dev; |
1596 ino_t sn_ino; | 1671 ino_t sn_ino; |
3689 EXPR_SEQUAL, // <= | 3764 EXPR_SEQUAL, // <= |
3690 EXPR_MATCH, // =~ | 3765 EXPR_MATCH, // =~ |
3691 EXPR_NOMATCH, // !~ | 3766 EXPR_NOMATCH, // !~ |
3692 EXPR_IS, // is | 3767 EXPR_IS, // is |
3693 EXPR_ISNOT, // isnot | 3768 EXPR_ISNOT, // isnot |
3769 // used with ISN_OPNR | |
3770 EXPR_ADD, // + | |
3771 EXPR_SUB, // - | |
3772 EXPR_MULT, // * | |
3773 EXPR_DIV, // / | |
3774 EXPR_REM, // % | |
3694 } exptype_T; | 3775 } exptype_T; |
3695 | 3776 |
3696 /* | 3777 /* |
3697 * Structure used for reading in json_decode(). | 3778 * Structure used for reading in json_decode(). |
3698 */ | 3779 */ |
3802 * "newkey" is the key for the new item. | 3883 * "newkey" is the key for the new item. |
3803 */ | 3884 */ |
3804 typedef struct lval_S | 3885 typedef struct lval_S |
3805 { | 3886 { |
3806 char_u *ll_name; // start of variable name (can be NULL) | 3887 char_u *ll_name; // start of variable name (can be NULL) |
3888 char_u *ll_name_end; // end of variable name (can be NULL) | |
3889 type_T *ll_type; // type of variable (can be NULL) | |
3807 char_u *ll_exp_name; // NULL or expanded name in allocated memory. | 3890 char_u *ll_exp_name; // NULL or expanded name in allocated memory. |
3808 typval_T *ll_tv; // Typeval of item being used. If "newkey" | 3891 typval_T *ll_tv; // Typeval of item being used. If "newkey" |
3809 // isn't NULL it's the Dict to which to add | 3892 // isn't NULL it's the Dict to which to add |
3810 // the item. | 3893 // the item. |
3811 listitem_T *ll_li; // The list item or NULL. | 3894 listitem_T *ll_li; // The list item or NULL. |