comparison src/structs.h @ 9723:80ac9cf77c9b v7.4.2137

commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 1 15:40:54 2016 +0200 patch 7.4.2137 Problem: Using function() with a name will find another function when it is redefined. Solution: Add funcref(). Refer to lambda using a partial. Fix several reference counting issues.
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Aug 2016 15:45:07 +0200
parents 172131507c85
children 02ba9b2f80e8
comparison
equal deleted inserted replaced
9722:1557241fd3a7 9723:80ac9cf77c9b
1293 dict_T *dv_copydict; /* copied dict used by deepcopy() */ 1293 dict_T *dv_copydict; /* copied dict used by deepcopy() */
1294 dict_T *dv_used_next; /* next dict in used dicts list */ 1294 dict_T *dv_used_next; /* next dict in used dicts list */
1295 dict_T *dv_used_prev; /* previous dict in used dicts list */ 1295 dict_T *dv_used_prev; /* previous dict in used dicts list */
1296 }; 1296 };
1297 1297
1298 #if defined(FEAT_EVAL) || defined(PROTO)
1299 typedef struct funccall_S funccall_T;
1300
1301 /*
1302 * Structure to hold info for a user function.
1303 */
1304 typedef struct
1305 {
1306 int uf_varargs; /* variable nr of arguments */
1307 int uf_flags;
1308 int uf_calls; /* nr of active calls */
1309 garray_T uf_args; /* arguments */
1310 garray_T uf_lines; /* function lines */
1311 #ifdef FEAT_PROFILE
1312 int uf_profiling; /* TRUE when func is being profiled */
1313 /* profiling the function as a whole */
1314 int uf_tm_count; /* nr of calls */
1315 proftime_T uf_tm_total; /* time spent in function + children */
1316 proftime_T uf_tm_self; /* time spent in function itself */
1317 proftime_T uf_tm_children; /* time spent in children this call */
1318 /* profiling the function per line */
1319 int *uf_tml_count; /* nr of times line was executed */
1320 proftime_T *uf_tml_total; /* time spent in a line + children */
1321 proftime_T *uf_tml_self; /* time spent in a line itself */
1322 proftime_T uf_tml_start; /* start time for current line */
1323 proftime_T uf_tml_children; /* time spent in children for this line */
1324 proftime_T uf_tml_wait; /* start wait time for current line */
1325 int uf_tml_idx; /* index of line being timed; -1 if none */
1326 int uf_tml_execed; /* line being timed was executed */
1327 #endif
1328 scid_T uf_script_ID; /* ID of script where function was defined,
1329 used for s: variables */
1330 int uf_refcount; /* for numbered function: reference count */
1331 funccall_T *uf_scoped; /* l: local variables for closure */
1332 char_u uf_name[1]; /* name of function (actually longer); can
1333 start with <SNR>123_ (<SNR> is K_SPECIAL
1334 KS_EXTRA KE_SNR) */
1335 } ufunc_T;
1336
1337 #define MAX_FUNC_ARGS 20 /* maximum number of function arguments */
1338 #define VAR_SHORT_LEN 20 /* short variable name length */
1339 #define FIXVAR_CNT 12 /* number of fixed variables */
1340
1341 /* structure to hold info for a function that is currently being executed. */
1342 struct funccall_S
1343 {
1344 ufunc_T *func; /* function being called */
1345 int linenr; /* next line to be executed */
1346 int returned; /* ":return" used */
1347 struct /* fixed variables for arguments */
1348 {
1349 dictitem_T var; /* variable (without room for name) */
1350 char_u room[VAR_SHORT_LEN]; /* room for the name */
1351 } fixvar[FIXVAR_CNT];
1352 dict_T l_vars; /* l: local function variables */
1353 dictitem_T l_vars_var; /* variable for l: scope */
1354 dict_T l_avars; /* a: argument variables */
1355 dictitem_T l_avars_var; /* variable for a: scope */
1356 list_T l_varlist; /* list for a:000 */
1357 listitem_T l_listitems[MAX_FUNC_ARGS]; /* listitems for a:000 */
1358 typval_T *rettv; /* return value */
1359 linenr_T breakpoint; /* next line with breakpoint or zero */
1360 int dbg_tick; /* debug_tick when breakpoint was set */
1361 int level; /* top nesting level of executed function */
1362 #ifdef FEAT_PROFILE
1363 proftime_T prof_child; /* time spent in a child */
1364 #endif
1365 funccall_T *caller; /* calling function or NULL */
1366
1367 /* for closure */
1368 int fc_refcount;
1369 int fc_copyID; /* for garbage collection */
1370 garray_T fc_funcs; /* list of ufunc_T* which refer this */
1371 };
1372
1373 /*
1374 * Struct used by trans_function_name()
1375 */
1376 typedef struct
1377 {
1378 dict_T *fd_dict; /* Dictionary used */
1379 char_u *fd_newkey; /* new key in "dict" in allocated memory */
1380 dictitem_T *fd_di; /* Dictionary item used */
1381 } funcdict_T;
1382
1383 #endif
1384
1298 struct partial_S 1385 struct partial_S
1299 { 1386 {
1300 int pt_refcount; /* reference count */ 1387 int pt_refcount; /* reference count */
1301 char_u *pt_name; /* function name */ 1388 char_u *pt_name; /* function name; when NULL use
1389 * pt_func->uf_name */
1390 ufunc_T *pt_func; /* function pointer; when NULL lookup function
1391 * with pt_name */
1302 int pt_auto; /* when TRUE the partial was created for using 1392 int pt_auto; /* when TRUE the partial was created for using
1303 dict.member in handle_subscript() */ 1393 dict.member in handle_subscript() */
1304 int pt_argc; /* number of arguments */ 1394 int pt_argc; /* number of arguments */
1305 typval_T *pt_argv; /* arguments in allocated array */ 1395 typval_T *pt_argv; /* arguments in allocated array */
1306 dict_T *pt_dict; /* dict for "self" */ 1396 dict_T *pt_dict; /* dict for "self" */