Is it transcoded down to C and compiled?
Vimscript is interpreted, and in fact you can do basically the same things in vimscript as you could at the :
command (and the other way around), plus or minus some bar and escape characters to make things sane.
The evaluation code is mainly located in eval.c
, which you can browse if you are brave.
Is it put on the heap at runtime and referenced through a function
pointer?
While a built-in function is ultimately a function pointer to the C implementation, a user function is represented by a ufunc_T
structure (trimmed of some stuff for brevity):
struct ufunc
{
int uf_varargs;
int uf_flags;
int uf_calls;
garray_T uf_args;
garray_T uf_lines;
scid_T uf_script_ID;
int uf_refcount;
char_u uf_name[1];
};
The function call_user_func
is used to actually make the call to a user function. After doing a ton of setup to initialize arguments, variables, profiling information and state management, call_user_func
does
do_cmdline(NULL, get_func_line, (void *)fc, DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);
to execute each line of the function as a :
command line (the implementation of do_cmdline
in in ex_docmd.c).