typval.h
Go to the documentation of this file.
1 #ifndef NVIM_EVAL_TYPVAL_H
2 #define NVIM_EVAL_TYPVAL_H
3 
4 #include <assert.h>
5 #include <inttypes.h>
6 #include <stdbool.h>
7 #include <stddef.h>
8 #include <string.h>
9 
10 #include "nvim/func_attr.h"
11 #include "nvim/garray.h"
12 #include "nvim/gettext.h"
13 #include "nvim/hashtab.h"
14 #include "nvim/lib/queue.h"
15 #include "nvim/macros.h"
16 #include "nvim/mbyte.h"
17 #include "nvim/message.h"
18 #include "nvim/pos.h" // for linenr_T
19 #include "nvim/profile.h" // for proftime_T
20 #include "nvim/types.h"
21 #ifdef LOG_LIST_ACTIONS
22 # include "nvim/memory.h"
23 #endif
24 
26 typedef int64_t varnumber_T;
27 typedef uint64_t uvarnumber_T;
28 
30 typedef double float_T;
31 
33 enum { DO_NOT_FREE_CNT = (INT_MAX / 2), };
34 
52 };
53 
55 #define VARNUMBER_MAX INT64_MAX
56 #define UVARNUMBER_MAX UINT64_MAX
57 
59 #define VARNUMBER_MIN INT64_MIN
60 
62 #define PRIdVARNUMBER PRId64
63 
64 typedef struct listvar_S list_T;
65 typedef struct dictvar_S dict_T;
66 typedef struct partial_S partial_T;
67 typedef struct blobvar_S blob_T;
68 
69 typedef struct ufunc ufunc_T;
70 
71 typedef enum {
76 } CallbackType;
77 
78 typedef struct {
79  union {
80  char *funcref;
83  } data;
85 } Callback;
86 
87 #define CALLBACK_INIT { .type = kCallbackNone }
88 #define CALLBACK_NONE ((Callback)CALLBACK_INIT)
89 
91 typedef struct dict_watcher {
93  char *key_pattern;
96  bool busy; // prevent recursion if the dict is changed in the callback
97  bool needs_free;
98 } DictWatcher;
99 
101 typedef enum {
104 } BoolVarValue;
105 
107 typedef enum {
110 
112 typedef enum {
115  VAR_FIXED = 2,
116 } VarLockStatus;
117 
119 typedef enum {
129  VAR_PARTIAL,
132 } VarType;
133 
135 typedef struct {
143  char *v_string;
148  } vval;
149 } typval_T;
150 
152 typedef enum {
154  VAR_SCOPE = 1,
156 } ScopeType;
158 
160 typedef struct listitem_S listitem_T;
161 
162 struct listitem_S {
166 };
167 
169 typedef struct listwatch_S listwatch_T;
170 
171 struct listwatch_S {
174 };
175 
178 struct listvar_S {
187  int lv_len;
188  int lv_idx;
189  int lv_copyID;
191 
193 };
194 
195 // Static list with 10 items. Use tv_list_init_static10() to initialize.
196 typedef struct {
197  list_T sl_list; // must be first
198  listitem_T sl_items[10];
200 
201 #define TV_LIST_STATIC10_INIT { \
202  .sl_list = { \
203  .lv_first = NULL, \
204  .lv_last = NULL, \
205  .lv_refcount = 0, \
206  .lv_len = 0, \
207  .lv_watch = NULL, \
208  .lv_idx_item = NULL, \
209  .lv_lock = VAR_FIXED, \
210  .lv_used_next = NULL, \
211  .lv_used_prev = NULL, \
212  }, \
213 }
214 
215 #define TV_DICTITEM_STRUCT(...) \
216  struct { \
217  typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
218  uint8_t di_flags; /* Flags. */ \
219  char_u di_key[__VA_ARGS__]; /* Key value. */ \
220  }
221 
228 typedef TV_DICTITEM_STRUCT(1) ScopeDictDictItem;
229 
236 
238 typedef enum {
244 } DictItemFlags;
245 
247 struct dictvar_S {
250  int dv_refcount;
252  int dv_copyID;
258 
260 };
261 
263 struct blobvar_S {
267 };
268 
270 typedef int scid_T;
272 #define PRIdSCID "d"
273 
274 // SCript ConteXt (SCTX): identifies a script line.
275 // When sourcing a script "sc_lnum" is zero, "sourcing_lnum" is the current
276 // line number. When executing a user function "sc_lnum" is the line where the
277 // function was defined, "sourcing_lnum" is the line number inside the
278 // function. When stored with a function, mapping, option, etc. "sc_lnum" is
279 // the line number in the script "sc_sid".
280 typedef struct {
281  scid_T sc_sid; // script ID
282  int sc_seq; // sourcing sequence number
283  linenr_T sc_lnum; // line number
284 } sctx_T;
285 
287 #define MAX_FUNC_ARGS 20
288 #define VAR_SHORT_LEN 20
290 #define FIXVAR_CNT 12
292 
295 typedef int (*cfunc_T)(int argcount, typval_T *argvars, typval_T *rettv, void *state); // NOLINT
297 typedef void (*cfunc_free_T)(void *state);
298 
299 // Structure to hold info for a function that is currently being executed.
300 typedef struct funccall_S funccall_T;
301 
302 struct funccall_S {
304  int linenr;
305  int returned;
309  ScopeDictDictItem l_vars_var;
311  ScopeDictDictItem l_avars_var;
316  int dbg_tick;
317  int level;
320  int fc_refcount;
322  int fc_copyID;
324 };
325 
327 struct ufunc {
329  int uf_flags;
330  int uf_calls;
331  bool uf_cleared;
337  // Managing cfuncs
340  void *uf_cb_state;
341  // Profiling the function as a whole.
346  // Profiling the function per line.
356  int uf_refcount;
359  char_u uf_name[];
360 };
363 
364 struct partial_S {
368  bool pt_auto;
370  int pt_argc;
374 };
375 
377 typedef struct ht_stack_S {
379  struct ht_stack_S *prev;
380 } ht_stack_T;
381 
383 typedef struct list_stack_S {
386 } list_stack_T;
387 
389 typedef struct {
391  int idx;
392 } ListSortItem;
393 
394 typedef int (*ListSorter)(const void *, const void *);
395 
396 #ifdef LOG_LIST_ACTIONS
397 
399 typedef struct {
400  uintptr_t l;
401  uintptr_t li1;
402  uintptr_t li2;
403  int len;
404  const char *action;
405 } ListLogEntry;
406 
407 typedef struct list_log ListLog;
408 
410 struct list_log {
411  ListLog *next;
412  size_t capacity;
413  size_t size;
414  ListLogEntry entries[];
415 };
416 
417 extern ListLog *list_log_first;
418 extern ListLog *list_log_last;
419 
420 static inline ListLog *list_log_alloc(const size_t size)
422 
428 static inline ListLog *list_log_new(const size_t size)
429 {
430  ListLog *ret = xmalloc(offsetof(ListLog, entries)
431  + size * sizeof(ret->entries[0]));
432  ret->size = 0;
433  ret->capacity = size;
434  ret->next = NULL;
435  if (list_log_first == NULL) {
436  list_log_first = ret;
437  } else {
438  list_log_last->next = ret;
439  }
440  list_log_last = ret;
441  return ret;
442 }
443 
444 static inline void list_log(const list_T *const l,
445  const listitem_T *const li1,
446  const listitem_T *const li2,
447  const char *const action)
449 
459 static inline void list_log(const list_T *const l, const listitem_T *const li1,
460  const listitem_T *const li2, const char *const action)
461 {
462  ListLog *tgt;
463  if (list_log_first == NULL) {
464  tgt = list_log_new(128);
465  } else if (list_log_last->size == list_log_last->capacity) {
466  tgt = list_log_new(list_log_last->capacity * 2);
467  } else {
468  tgt = list_log_last;
469  }
470  tgt->entries[tgt->size++] = (ListLogEntry) {
471  .l = (uintptr_t)l,
472  .li1 = (uintptr_t)li1,
473  .li2 = (uintptr_t)li2,
474  .len = (l == NULL ? 0 : l->lv_len),
475  .action = action,
476  };
477 }
478 #else
479 # define list_log(...)
480 # define list_write_log(...)
481 # define list_free_log()
482 #endif
483 
484 // In a hashtab item "hi_key" points to "di_key" in a dictitem.
485 // This avoids adding a pointer to the hashtab item.
486 
488 #define TV_DICT_HI2DI(hi) \
489  ((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key)))
490 
491 static inline void tv_list_ref(list_T *const l)
493 
499 static inline void tv_list_ref(list_T *const l)
500 {
501  if (l == NULL) {
502  return;
503  }
504  l->lv_refcount++;
505 }
506 
507 static inline void tv_list_set_ret(typval_T *const tv, list_T *const l)
509 
514 static inline void tv_list_set_ret(typval_T *const tv, list_T *const l)
515 {
516  tv->v_type = VAR_LIST;
517  tv->vval.v_list = l;
518  tv_list_ref(l);
519 }
520 
521 static inline VarLockStatus tv_list_locked(const list_T *const l)
523 
529 static inline VarLockStatus tv_list_locked(const list_T *const l)
530 {
531  if (l == NULL) {
532  return VAR_FIXED;
533  }
534  return l->lv_lock;
535 }
536 
543 static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
544 {
545  if (l == NULL) {
546  assert(lock == VAR_FIXED);
547  return;
548  }
549  l->lv_lock = lock;
550 }
551 
558 static inline void tv_list_set_copyid(list_T *const l, const int copyid)
560 {
561  l->lv_copyID = copyid;
562 }
563 
564 static inline int tv_list_len(const list_T *const l)
566 
570 static inline int tv_list_len(const list_T *const l)
571 {
572  list_log(l, NULL, NULL, "len");
573  if (l == NULL) {
574  return 0;
575  }
576  return l->lv_len;
577 }
578 
579 static inline int tv_list_copyid(const list_T *const l)
581 
587 static inline int tv_list_copyid(const list_T *const l)
588 {
589  return l->lv_copyID;
590 }
591 
592 static inline list_T *tv_list_latest_copy(const list_T *const l)
594 
602 static inline list_T *tv_list_latest_copy(const list_T *const l)
603 {
604  return l->lv_copylist;
605 }
606 
607 static inline int tv_list_uidx(const list_T *const l, int n)
609 
616 static inline int tv_list_uidx(const list_T *const l, int n)
617 {
618  // Negative index is relative to the end.
619  if (n < 0) {
620  n += tv_list_len(l);
621  }
622 
623  // Check for index out of range.
624  if (n < 0 || n >= tv_list_len(l)) {
625  return -1;
626  }
627  return n;
628 }
629 
630 static inline bool tv_list_has_watchers(const list_T *const l)
632 
640 static inline bool tv_list_has_watchers(const list_T *const l)
641 {
642  return l && l->lv_watch;
643 }
644 
645 static inline listitem_T *tv_list_first(const list_T *const l)
647 
653 static inline listitem_T *tv_list_first(const list_T *const l)
654 {
655  if (l == NULL) {
656  list_log(l, NULL, NULL, "first");
657  return NULL;
658  }
659  list_log(l, l->lv_first, NULL, "first");
660  return l->lv_first;
661 }
662 
663 static inline listitem_T *tv_list_last(const list_T *const l)
665 
671 static inline listitem_T *tv_list_last(const list_T *const l)
672 {
673  if (l == NULL) {
674  list_log(l, NULL, NULL, "last");
675  return NULL;
676  }
677  list_log(l, l->lv_last, NULL, "last");
678  return l->lv_last;
679 }
680 
681 static inline void tv_dict_set_ret(typval_T *const tv, dict_T *const d)
683 
688 static inline void tv_dict_set_ret(typval_T *const tv, dict_T *const d)
689 {
690  tv->v_type = VAR_DICT;
691  tv->vval.v_dict = d;
692  if (d != NULL) {
693  d->dv_refcount++;
694  }
695 }
696 
697 static inline long tv_dict_len(const dict_T *const d)
699 
703 static inline long tv_dict_len(const dict_T *const d)
704 {
705  if (d == NULL) {
706  return 0L;
707  }
708  return (long)d->dv_hashtab.ht_used;
709 }
710 
711 static inline bool tv_dict_is_watched(const dict_T *const d)
713 
719 static inline bool tv_dict_is_watched(const dict_T *const d)
720 {
721  return d && !QUEUE_EMPTY(&d->watchers);
722 }
723 
724 static inline void tv_blob_set_ret(typval_T *const tv, blob_T *const b)
726 
733 static inline void tv_blob_set_ret(typval_T *const tv, blob_T *const b)
734 {
735  tv->v_type = VAR_BLOB;
736  tv->vval.v_blob = b;
737  if (b != NULL) {
738  b->bv_refcount++;
739  }
740 }
741 
742 static inline int tv_blob_len(const blob_T *const b)
744 
748 static inline int tv_blob_len(const blob_T *const b)
749 {
750  if (b == NULL) {
751  return 0;
752  }
753  return b->bv_ga.ga_len;
754 }
755 
756 static inline char_u tv_blob_get(const blob_T *const b, int idx)
758 
765 static inline char_u tv_blob_get(const blob_T *const b, int idx)
766 {
767  return ((char_u *)b->bv_ga.ga_data)[idx];
768 }
769 
770 static inline void tv_blob_set(blob_T *const b, int idx, char_u c)
772 
778 static inline void tv_blob_set(blob_T *const b, int idx, char_u c)
779 {
780  ((char_u *)b->bv_ga.ga_data)[idx] = c;
781 }
782 
788 static inline void tv_init(typval_T *const tv)
789 {
790  if (tv != NULL) {
791  memset(tv, 0, sizeof(*tv));
792  }
793 }
794 
795 #define TV_INITIAL_VALUE \
796  ((typval_T) { \
797  .v_type = VAR_UNKNOWN, \
798  .v_lock = VAR_UNLOCKED, \
799  })
800 
805 extern const char *const tv_empty_string;
806 
808 extern bool tv_in_free_unref_items;
809 
817 #define _TV_LIST_ITER_MOD(modifier, l, li, code) \
818  do { \
819  modifier list_T *const l_ = (l); \
820  list_log(l_, NULL, NULL, "iter" #modifier); \
821  if (l_ != NULL) { \
822  for (modifier listitem_T *li = l_->lv_first; \
823  li != NULL; li = li->li_next) { \
824  code \
825  } \
826  } \
827  } while (0)
828 
837 #define TV_LIST_ITER(l, li, code) \
838  _TV_LIST_ITER_MOD( , l, li, code)
839 
848 #define TV_LIST_ITER_CONST(l, li, code) \
849  _TV_LIST_ITER_MOD(const, l, li, code)
850 
851 // Below macros are macros to avoid duplicating code for functionally identical
852 // const and non-const function variants.
853 
859 #define TV_LIST_ITEM_TV(li) (&(li)->li_tv)
860 
867 #define TV_LIST_ITEM_NEXT(l, li) ((li)->li_next)
868 
875 #define TV_LIST_ITEM_PREV(l, li) ((li)->li_prev)
876 // List argument is not used currently, but it is a must for lists implemented
877 // as a pair (size(in list), array) without terminator - basically for lists on
878 // top of kvec.
879 
885 #define TV_DICT_ITER(d, di, code) \
886  HASHTAB_ITER(&(d)->dv_hashtab, di##hi_, { \
887  { \
888  dictitem_T *const di = TV_DICT_HI2DI(di##hi_); \
889  { \
890  code \
891  } \
892  } \
893  })
894 
895 static inline bool tv_get_float_chk(const typval_T *const tv,
896  float_T *const ret_f)
898 
899 // FIXME circular dependency, cannot import message.h.
900 bool semsg(const char *const fmt, ...);
901 
910 static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret_f)
911 {
912  if (tv->v_type == VAR_FLOAT) {
913  *ret_f = tv->vval.v_float;
914  return true;
915  }
916  if (tv->v_type == VAR_NUMBER) {
917  *ret_f = (float_T)tv->vval.v_number;
918  return true;
919  }
920  semsg("%s", _("E808: Number or Float required"));
921  return false;
922 }
923 
924 static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q)
927 
932 static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q)
933 {
934  return QUEUE_DATA(q, DictWatcher, node);
935 }
936 
937 static inline bool tv_is_func(const typval_T tv)
939 
947 static inline bool tv_is_func(const typval_T tv)
948 {
949  return tv.v_type == VAR_FUNC || tv.v_type == VAR_PARTIAL;
950 }
951 
956 #define TV_TRANSLATE (SIZE_MAX)
957 
961 #define TV_CSTRING (SIZE_MAX - 1)
962 
963 #ifdef UNIT_TESTING
964 // Do not use enum constants, see commit message.
965 EXTERN const size_t kTVCstring INIT(= TV_CSTRING);
966 EXTERN const size_t kTVTranslate INIT(= TV_TRANSLATE);
967 #endif
968 
969 #ifdef INCLUDE_GENERATED_DECLARATIONS
970 # include "eval/typval.h.generated.h"
971 #endif
972 #endif // NVIM_EVAL_TYPVAL_H
listvar_S::lv_first
listitem_T * lv_first
First item, NULL if none.
Definition: typval.h:179
funccall_S::l_vars
dict_T l_vars
l: local function variables.
Definition: typval.h:308
FUNC_ATTR_CONST
#define FUNC_ATTR_CONST
Definition: func_attr.h:243
ufunc::uf_tml_self
proftime_T * uf_tml_self
time spent in a line itself
Definition: typval.h:349
listvar_S::lua_table_ref
LuaRef lua_table_ref
Definition: typval.h:192
listvar_S::lv_last
listitem_T * lv_last
Last item, NULL if none.
Definition: typval.h:180
blobvar_S::bv_ga
garray_T bv_ga
Growarray with the data.
Definition: typval.h:264
ufunc::uf_tml_total
proftime_T * uf_tml_total
time spent in a line + children
Definition: typval.h:348
ufunc::uf_tm_total
proftime_T uf_tm_total
time spent in function + children
Definition: typval.h:343
VAR_FLOAT
@ VAR_FLOAT
Floating-point value, .v_float is used.
Definition: typval.h:126
listvar_S::lv_idx_item
listitem_T * lv_idx_item
When not NULL item at index "lv_idx".
Definition: typval.h:182
profile.h
ht_stack_S::prev
struct ht_stack_S * prev
Definition: typval.h:379
partial_S::pt_func
ufunc_T * pt_func
Definition: typval.h:367
VAR_SCOPE
@ VAR_SCOPE
Scope dictionary which requires prefix (a:, v:, …).
Definition: typval.h:154
typval_T::typval_vval_union::v_special
SpecialVarValue v_special
Special value, for VAR_SPECIAL.
Definition: typval.h:141
uvarnumber_T
uint64_t uvarnumber_T
Definition: typval.h:27
partial_S::pt_dict
dict_T * pt_dict
Dict for "self".
Definition: typval.h:373
_queue
Definition: queue.h:27
tv
typval_T tv
Definition: typval.c:1705
ListSorter
int(* ListSorter)(const void *, const void *)
Definition: typval.h:394
typval_T::typval_vval_union::v_number
varnumber_T v_number
Number, for VAR_NUMBER.
Definition: typval.h:139
DI_FLAGS_ALLOC
@ DI_FLAGS_ALLOC
Separately allocated.
Definition: typval.h:243
_
#define _(x)
Definition: gettext.h:20
CallbackType
CallbackType
Definition: typval.h:71
tv_empty_string
const char *const tv_empty_string
Definition: typval.c:48
dictvar_S::dv_copyID
int dv_copyID
ID used when recursivery traversing a value.
Definition: typval.h:252
ufunc::uf_tml_wait
proftime_T uf_tml_wait
start wait time for current line
Definition: typval.h:352
VarType
VarType
VimL variable types, for use in typval_T.v_type.
Definition: typval.h:119
typval_T
Structure that holds an internal variable value.
Definition: typval.h:135
listvar_S::lv_len
int lv_len
Number of items.
Definition: typval.h:187
REAL_FATTR_NONNULL_RET
#define REAL_FATTR_NONNULL_RET
Definition: func_attr.h:191
typval_T::typval_vval_union::v_partial
partial_T * v_partial
Closure: function with args.
Definition: typval.h:146
list_log
#define list_log(...)
Definition: typval.h:479
types.h
funccall_S::l_varlist
list_T l_varlist
List for a:000.
Definition: typval.h:312
ufunc::uf_flags
int uf_flags
Definition: typval.h:329
funccall_S::breakpoint
linenr_T breakpoint
Next line with breakpoint or zero.
Definition: typval.h:315
dict_watcher::node
QUEUE node
Definition: typval.h:95
funccall_S::rettv
typval_T * rettv
Return value.
Definition: typval.h:314
VAR_STRING
@ VAR_STRING
String, .v_string is used.
Definition: typval.h:122
dictvar_S::dv_hashtab
hashtab_T dv_hashtab
Hashtab containing all items.
Definition: typval.h:253
listvar_S
Definition: typval.h:178
ufunc::uf_varargs
int uf_varargs
variable nr of arguments
Definition: typval.h:328
kCallbackFuncref
@ kCallbackFuncref
Definition: typval.h:73
ScopeType
ScopeType
Values for (struct dictvar_S).dv_scope.
Definition: typval.h:152
ufunc::uf_tml_execed
int uf_tml_execed
line being timed was executed
Definition: typval.h:354
size
size_t size
Definition: regexp_nfa.c:5986
funccall_S::fc_refcount
int fc_refcount
Number of user functions that reference this funccall.
Definition: typval.h:321
VAR_UNKNOWN
@ VAR_UNKNOWN
Unknown (unspecified) value.
Definition: typval.h:120
funccall_S::returned
int returned
Definition: typval.h:305
Callback::type
CallbackType type
Definition: typval.h:84
dictvar_S::dv_refcount
int dv_refcount
Reference count.
Definition: typval.h:251
listvar_S::lv_copyID
int lv_copyID
ID used by deepcopy().
Definition: typval.h:189
assert.h
VAR_FIXED
@ VAR_FIXED
Locked forever.
Definition: typval.h:115
dict_watcher::key_pattern
char * key_pattern
Definition: typval.h:93
ufunc::uf_tml_start
proftime_T uf_tml_start
start time for current line
Definition: typval.h:350
xmalloc
void * xmalloc(size_t size) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1) FUNC_ATTR_NONNULL_RET
Definition: memory.c:105
blobvar_S
Structure to hold info about a Blob.
Definition: typval.h:263
listwatch_S::lw_next
listwatch_T * lw_next
Next watcher.
Definition: typval.h:173
VAR_NO_SCOPE
@ VAR_NO_SCOPE
Not a scope dictionary.
Definition: typval.h:153
dict_watcher::key_pattern_len
size_t key_pattern_len
Definition: typval.h:94
DI_FLAGS_FIX
@ DI_FLAGS_FIX
Fixed value: cannot be :unlet or remove()d.
Definition: typval.h:241
macros.h
TV_TRANSLATE
#define TV_TRANSLATE
Definition: typval.h:956
hashtable_S
Definition: hashtab.h:63
semsg
bool semsg(const char *const fmt,...)
Print an error message with unknown number of arguments.
QUEUE_DATA
#define QUEUE_DATA(ptr, type, field)
Definition: queue.h:33
cfunc_T
int(* cfunc_T)(int argcount, typval_T *argvars, typval_T *rettv, void *state)
Definition: typval.h:295
typval_T::typval_vval_union::v_string
char * v_string
String, for VAR_STRING and VAR_FUNC, can be NULL.
Definition: typval.h:143
ufunc::uf_tm_children
proftime_T uf_tm_children
time spent in children this call
Definition: typval.h:345
funccall_S::l_listitems
listitem_T l_listitems[MAX_FUNC_ARGS]
List items for a:000.
Definition: typval.h:313
kCallbackLua
@ kCallbackLua
Definition: typval.h:75
typval_T::typval_vval_union::v_list
list_T * v_list
List for VAR_LIST, can be NULL.
Definition: typval.h:144
kBoolVarFalse
@ kBoolVarFalse
v:false
Definition: typval.h:102
typval_T::typval_vval_union::v_float
float_T v_float
Floating-point number, for VAR_FLOAT.
Definition: typval.h:142
ht_stack_S::ht
hashtab_T * ht
Definition: typval.h:378
ListLenSpecials
ListLenSpecials
Additional values for tv_list_alloc() len argument.
Definition: typval.h:36
hashtab.h
ret
const int ret
Definition: eval.c:746
typval_T::typval_vval_union::v_bool
BoolVarValue v_bool
Bool value, for VAR_BOOL.
Definition: typval.h:140
kListLenShouldKnow
@ kListLenShouldKnow
Definition: typval.h:47
void
void(WINAPI *pClosePseudoConsole)(HPCON)
funccall_S::fc_funcs
garray_T fc_funcs
List of ufunc_T* which keep a reference to "func".
Definition: typval.h:323
INIT
#define INIT(...)
Definition: macros.h:10
listvar_S::lv_used_next
list_T * lv_used_next
next list in used lists list.
Definition: typval.h:184
typval_T::v_type
VarType v_type
Variable type.
Definition: typval.h:136
dict_watcher::needs_free
bool needs_free
Definition: typval.h:97
TV_CSTRING
#define TV_CSTRING
Definition: typval.h:961
staticList10_T
Definition: typval.h:196
growarray::ga_data
void * ga_data
Definition: garray.h:17
ufunc::uf_tm_self
proftime_T uf_tm_self
time spent in function itself
Definition: typval.h:344
sctx_T::sc_sid
scid_T sc_sid
Definition: typval.h:281
sctx_T
Definition: typval.h:280
LuaRef
int LuaRef
Definition: types.h:23
ufunc::uf_tml_count
int * uf_tml_count
nr of times line was executed
Definition: typval.h:347
kListLenUnknown
@ kListLenUnknown
Definition: typval.h:41
growarray
Definition: garray.h:12
funccall_S::linenr
int linenr
Next line to be executed.
Definition: typval.h:304
VarLockStatus
VarLockStatus
Variable lock status for typval_T.v_lock.
Definition: typval.h:112
listwatch_S::lw_item
listitem_T * lw_item
Item being watched.
Definition: typval.h:172
partial_S::pt_argv
typval_T * pt_argv
Arguments in allocated array.
Definition: typval.h:372
growarray::ga_len
int ga_len
Definition: garray.h:13
REAL_FATTR_NONNULL_ALL
#define REAL_FATTR_NONNULL_ALL
Definition: func_attr.h:183
mbyte.h
scid_T
int scid_T
Type used for script ID.
Definition: typval.h:270
typval_T::v_lock
VarLockStatus v_lock
Variable lock status.
Definition: typval.h:137
dict_watcher
Structure holding dictionary watcher.
Definition: typval.h:91
ListSortItem::item
listitem_T * item
Sorted list item.
Definition: typval.h:390
funccall_S::caller
funccall_T * caller
Definition: typval.h:319
BoolVarValue
BoolVarValue
Bool variable values.
Definition: typval.h:101
message.h
ufunc::uf_prof_initialized
int uf_prof_initialized
Definition: typval.h:336
cfunc_free_T
void(* cfunc_free_T)(void *state)
Callback to clear cfunc_T and any associated state.
Definition: typval.h:297
VAR_PARTIAL
@ VAR_PARTIAL
Partial, .v_partial is used.
Definition: typval.h:130
VAR_BOOL
@ VAR_BOOL
true, false
Definition: typval.h:127
n
int n
Definition: funcs.c:8317
list_stack_T
struct list_stack_S list_stack_T
Structure used for explicit stack while garbage collecting lists.
tv_in_free_unref_items
bool tv_in_free_unref_items
Specifies that free_unref_items() function has (not) been entered.
Definition: typval.c:42
ufunc
Structure to hold info for a user function.
Definition: typval.h:327
typval_T::typval_vval_union::v_blob
blob_T * v_blob
Blob for VAR_BLOB, can be NULL.
Definition: typval.h:147
typval_T::typval_vval_union::v_dict
dict_T * v_dict
Dictionary for VAR_DICT, can be NULL.
Definition: typval.h:145
VAR_BLOB
@ VAR_BLOB
Blob, .v_blob is used.
Definition: typval.h:131
VAR_LIST
@ VAR_LIST
List, .v_list is used.
Definition: typval.h:124
memset
memset(lp, 0, sizeof(lval_T))
listvar_S::lv_copylist
list_T * lv_copylist
Copied list used by deepcopy().
Definition: typval.h:183
ufunc::uf_cleared
bool uf_cleared
func_clear() was already called
Definition: typval.h:331
ufunc::uf_lines
garray_T uf_lines
function lines
Definition: typval.h:334
VAR_UNLOCKED
@ VAR_UNLOCKED
Not locked.
Definition: typval.h:113
ht_stack_S
Structure used for explicit stack while garbage collecting hash tables.
Definition: typval.h:377
DictItemFlags
DictItemFlags
Flags for dictitem_T.di_flags.
Definition: typval.h:238
action
char action
Definition: funcs.c:8779
VAR_SPECIAL
@ VAR_SPECIAL
Definition: typval.h:128
kCallbackPartial
@ kCallbackPartial
Definition: typval.h:74
list_stack_S::list
list_T * list
Definition: typval.h:384
ufunc::uf_scoped
funccall_T * uf_scoped
l: local variables for closure
Definition: typval.h:358
gettext.h
float_T
double float_T
Type used for VimL VAR_FLOAT values.
Definition: typval.h:30
VAR_SHORT_LEN
#define VAR_SHORT_LEN
Short variable name length.
Definition: typval.h:289
funccall_S::level
int level
Top nesting level of executed function.
Definition: typval.h:317
funccall_S::func
ufunc_T * func
Function being called.
Definition: typval.h:303
ht_stack_T
struct ht_stack_S ht_stack_T
Structure used for explicit stack while garbage collecting hash tables.
FUNC_ATTR_NONNULL_ALL
#define FUNC_ATTR_NONNULL_ALL
Definition: func_attr.h:247
partial_S
Definition: typval.h:364
funccall_S::l_avars_var
ScopeDictDictItem l_avars_var
Variable for a: scope.
Definition: typval.h:311
queue.h
VAR_NUMBER
@ VAR_NUMBER
Number, .v_number is used.
Definition: typval.h:121
partial_S::pt_refcount
int pt_refcount
Reference count.
Definition: typval.h:365
assert
assert(len >=0)
ufunc::uf_cb_state
void * uf_cb_state
State of C function extension.
Definition: typval.h:340
varnumber_T
int64_t varnumber_T
Type used for VimL VAR_NUMBER values.
Definition: typval.h:26
ufunc::uf_tml_idx
int uf_tml_idx
index of line being timed; -1 if none
Definition: typval.h:353
funccall_S::dbg_tick
int dbg_tick
Debug_tick when breakpoint was set.
Definition: typval.h:316
ufunc::uf_calls
int uf_calls
nr of active calls
Definition: typval.h:330
typval_T::vval
union typval_T::typval_vval_union vval
Actual value.
DictWatcher
struct dict_watcher DictWatcher
Structure holding dictionary watcher.
DI_FLAGS_RO
@ DI_FLAGS_RO
Read-only value.
Definition: typval.h:239
listvar_S::lv_used_prev
list_T * lv_used_prev
Previous list in used lists list.
Definition: typval.h:185
dictvar_S::dv_used_next
dict_T * dv_used_next
Next dictionary in used dictionaries list.
Definition: typval.h:255
ufunc::uf_script_ctx
sctx_T uf_script_ctx
Definition: typval.h:355
dict_watcher::callback
Callback callback
Definition: typval.h:92
dictvar_S::watchers
QUEUE watchers
Dictionary key watchers set by user code.
Definition: typval.h:257
ufunc::uf_tml_children
proftime_T uf_tml_children
time spent in children for this line
Definition: typval.h:351
listvar_S::lv_watch
listwatch_T * lv_watch
First watcher, NULL if none.
Definition: typval.h:181
listwatch_S
Definition: typval.h:171
VAR_DEF_SCOPE
@ VAR_DEF_SCOPE
Definition: typval.h:155
REAL_FATTR_NONNULL_ARG
#define REAL_FATTR_NONNULL_ARG(...)
Definition: func_attr.h:187
sctx_T::sc_lnum
linenr_T sc_lnum
Definition: typval.h:283
listvar_S::lv_refcount
int lv_refcount
Reference count.
Definition: typval.h:186
EXTERN
#define EXTERN
Definition: macros.h:9
ListSortItem::idx
int idx
Sorted list item index.
Definition: typval.h:391
ufunc::uf_def_args
garray_T uf_def_args
default argument expressions
Definition: typval.h:333
typval_T::typval_vval_union
Definition: typval.h:138
ufunc::uf_cb_free
cfunc_free_T uf_cb_free
C function extension free callback.
Definition: typval.h:339
VAR_FUNC
@ VAR_FUNC
Function reference, .v_string is used as function name.
Definition: typval.h:123
TV_DICTITEM_STRUCT
#define TV_DICTITEM_STRUCT(...)
Definition: typval.h:215
list_stack_S::prev
struct list_stack_S * prev
Definition: typval.h:385
next
m next
Definition: match.c:207
Callback::luaref
LuaRef luaref
Definition: typval.h:82
listvar_S::lv_lock
VarLockStatus lv_lock
Zero, VAR_LOCKED, VAR_FIXED.
Definition: typval.h:190
funccall_S::fc_copyID
int fc_copyID
CopyID used for garbage collection.
Definition: typval.h:322
proftime_T
uint64_t proftime_T
Definition: profile.h:7
dictvar_S::lua_table_ref
LuaRef lua_table_ref
Definition: typval.h:259
listitem_S::li_next
listitem_T * li_next
Next item in list.
Definition: typval.h:163
FUNC_ATTR_WARN_UNUSED_RESULT
#define FUNC_ATTR_WARN_UNUSED_RESULT
Definition: func_attr.h:244
rettv
typval_T rettv
Definition: typval.c:1309
dictitem_T
Definition: coverity-model.c:39
dictvar_S::dv_scope
ScopeType dv_scope
Definition: typval.h:249
listitem_S
Definition: typval.h:162
funccall_S::l_avars
dict_T l_avars
a: argument variables.
Definition: typval.h:310
VAR_LOCKED
@ VAR_LOCKED
User lock, can be unlocked.
Definition: typval.h:114
partial_S::pt_name
char_u * pt_name
Function name; when NULL use pt_func->name.
Definition: typval.h:366
l
list_T *const l
Definition: funcs.c:8833
char_u
unsigned char char_u
Definition: types.h:12
dictvar_S
Structure representing a Dictionary.
Definition: typval.h:247
staticList10_T::sl_list
list_T sl_list
Definition: typval.h:197
blobvar_S::bv_lock
VarLockStatus bv_lock
VAR_UNLOCKED, VAR_LOCKED, VAR_FIXED.
Definition: typval.h:266
funccall_S::prof_child
proftime_T prof_child
Time spent in a child.
Definition: typval.h:318
ufunc::uf_tm_count
int uf_tm_count
nr of calls
Definition: typval.h:342
Callback
Definition: typval.h:78
garray.h
dictvar_S::dv_lock
VarLockStatus dv_lock
Whole dictionary lock status.
Definition: typval.h:248
dictvar_S::dv_copydict
dict_T * dv_copydict
Copied dict used by deepcopy().
Definition: typval.h:254
REAL_FATTR_PURE
#define REAL_FATTR_PURE
Definition: func_attr.h:163
ufunc::uf_profiling
int uf_profiling
true when func is being profiled
Definition: typval.h:335
ufunc::uf_args
garray_T uf_args
arguments
Definition: typval.h:332
listvar_S::lv_idx
int lv_idx
Index of a cached item, used for optimising repeated l[idx].
Definition: typval.h:188
FIXVAR_CNT
#define FIXVAR_CNT
Number of fixed variables used for arguments.
Definition: typval.h:291
DI_FLAGS_RO_SBX
@ DI_FLAGS_RO_SBX
Value, read-only in the sandbox.
Definition: typval.h:240
dict_T
Definition: coverity-model.c:40
dictvar_S::dv_used_prev
dict_T * dv_used_prev
Previous dictionary in used dictionaries list.
Definition: typval.h:256
kBoolVarTrue
@ kBoolVarTrue
v:true
Definition: typval.h:103
kSpecialVarNull
@ kSpecialVarNull
v:null
Definition: typval.h:108
VAR_DICT
@ VAR_DICT
Dictionary, .v_dict is used.
Definition: typval.h:125
sctx_T::sc_seq
int sc_seq
Definition: typval.h:282
func_attr.h
list_stack_S
Structure used for explicit stack while garbage collecting lists.
Definition: typval.h:383
REAL_FATTR_ALWAYS_INLINE
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition: typval_encode.c.h:265
Callback::funcref
char * funcref
Definition: typval.h:80
ListSortItem
Structure representing one list item, used for sort array.
Definition: typval.h:389
funccall_S::l_vars_var
ScopeDictDictItem l_vars_var
Variable for l: scope.
Definition: typval.h:309
FUNC_ATTR_ALWAYS_INLINE
#define FUNC_ATTR_ALWAYS_INLINE
Definition: func_attr.h:245
kListLenMayKnow
@ kListLenMayKnow
Definition: typval.h:51
listitem_S::li_tv
typval_T li_tv
Item value.
Definition: typval.h:165
funccall_S
Definition: typval.h:302
linenr_T
long linenr_T
Line number type.
Definition: pos.h:5
SpecialVarValue
SpecialVarValue
Special variable values.
Definition: typval.h:107
funccall_S::TV_DICTITEM_STRUCT
TV_DICTITEM_STRUCT(VAR_SHORT_LEN+1) fixvar[FIXVAR_CNT]
Fixed variables for arguments.
ufunc::uf_cb
cfunc_T uf_cb
C function extension callback.
Definition: typval.h:338
dict_watcher::busy
bool busy
Definition: typval.h:96
memory.h
NULL
return NULL
Definition: eval.c:9968
REAL_FATTR_WARN_UNUSED_RESULT
static int REAL_FATTR_WARN_UNUSED_RESULT
Definition: typval_encode.c.h:300
Callback::partial
partial_T * partial
Definition: typval.h:81
len
int len
Definition: helpers.c:1105
DI_FLAGS_LOCK
@ DI_FLAGS_LOCK
Locked value.
Definition: typval.h:242
kCallbackNone
@ kCallbackNone
Definition: typval.h:72
pos.h
listitem_S::li_prev
listitem_T * li_prev
Previous item in list.
Definition: typval.h:164
blobvar_S::bv_refcount
int bv_refcount
Reference count.
Definition: typval.h:265
MAX_FUNC_ARGS
#define MAX_FUNC_ARGS
Maximum number of function arguments.
Definition: typval.h:287
DO_NOT_FREE_CNT
@ DO_NOT_FREE_CNT
Definition: typval.h:33