mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 17:58:18 +00:00
@@ -151,6 +151,7 @@ set(CONV_SOURCES
|
|||||||
edit.c
|
edit.c
|
||||||
eval.c
|
eval.c
|
||||||
eval/funcs.c
|
eval/funcs.c
|
||||||
|
eval/userfunc.c
|
||||||
ex_cmds.c
|
ex_cmds.c
|
||||||
ex_docmd.c
|
ex_docmd.c
|
||||||
fileio.c
|
fileio.c
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include "nvim/edit.h"
|
#include "nvim/edit.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/typval.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/fileio.h"
|
#include "nvim/fileio.h"
|
||||||
#include "nvim/ops.h"
|
#include "nvim/ops.h"
|
||||||
#include "nvim/option.h"
|
#include "nvim/option.h"
|
||||||
|
3464
src/nvim/eval.c
3464
src/nvim/eval.c
File diff suppressed because it is too large
Load Diff
@@ -15,13 +15,6 @@
|
|||||||
// All user-defined functions are found in this hashtable.
|
// All user-defined functions are found in this hashtable.
|
||||||
extern hashtab_T func_hashtab;
|
extern hashtab_T func_hashtab;
|
||||||
|
|
||||||
///< Structure used by trans_function_name()
|
|
||||||
typedef struct {
|
|
||||||
dict_T *fd_dict; ///< Dictionary used.
|
|
||||||
char_u *fd_newkey; ///< New key in "dict" in allocated memory.
|
|
||||||
dictitem_T *fd_di; ///< Dictionary item used.
|
|
||||||
} funcdict_T;
|
|
||||||
|
|
||||||
// From user function to hashitem and back.
|
// From user function to hashitem and back.
|
||||||
EXTERN ufunc_T dumuf;
|
EXTERN ufunc_T dumuf;
|
||||||
#define UF2HIKEY(fp) ((fp)->uf_name)
|
#define UF2HIKEY(fp) ((fp)->uf_name)
|
||||||
@@ -187,9 +180,6 @@ extern const list_T *eval_msgpack_type_lists[LAST_MSGPACK_TYPE + 1];
|
|||||||
|
|
||||||
#undef LAST_MSGPACK_TYPE
|
#undef LAST_MSGPACK_TYPE
|
||||||
|
|
||||||
typedef int (*ArgvFunc)(int current_argcount, typval_T *argv, int argskip,
|
|
||||||
int called_func_argcount);
|
|
||||||
|
|
||||||
/// trans_function_name() flags
|
/// trans_function_name() flags
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TFN_INT = 1, ///< May use internal function name
|
TFN_INT = 1, ///< May use internal function name
|
||||||
@@ -242,6 +232,9 @@ typedef enum {
|
|||||||
kDictListItems, ///< List dictionary contents: [keys, values].
|
kDictListItems, ///< List dictionary contents: [keys, values].
|
||||||
} DictListType;
|
} DictListType;
|
||||||
|
|
||||||
|
// Used for checking if local variables or arguments used in a lambda.
|
||||||
|
extern bool *eval_lavars_used;
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "eval.h.generated.h"
|
# include "eval.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include "nvim/eval/encode.h"
|
#include "nvim/eval/encode.h"
|
||||||
#include "nvim/eval/executor.h"
|
#include "nvim/eval/executor.h"
|
||||||
#include "nvim/eval/funcs.h"
|
#include "nvim/eval/funcs.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/ex_getln.h"
|
#include "nvim/ex_getln.h"
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "nvim/eval/encode.h"
|
#include "nvim/eval/encode.h"
|
||||||
#include "nvim/eval/typval_encode.h"
|
#include "nvim/eval/typval_encode.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/types.h"
|
#include "nvim/types.h"
|
||||||
#include "nvim/assert.h"
|
#include "nvim/assert.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
|
@@ -258,9 +258,39 @@ typedef struct {
|
|||||||
linenr_T sc_lnum; // line number
|
linenr_T sc_lnum; // line number
|
||||||
} sctx_T;
|
} sctx_T;
|
||||||
|
|
||||||
|
/// Maximum number of function arguments
|
||||||
|
#define MAX_FUNC_ARGS 20
|
||||||
|
/// Short variable name length
|
||||||
|
#define VAR_SHORT_LEN 20
|
||||||
|
/// Number of fixed variables used for arguments
|
||||||
|
#define FIXVAR_CNT 12
|
||||||
|
|
||||||
// Structure to hold info for a function that is currently being executed.
|
// Structure to hold info for a function that is currently being executed.
|
||||||
typedef struct funccall_S funccall_T;
|
typedef struct funccall_S funccall_T;
|
||||||
|
|
||||||
|
struct funccall_S {
|
||||||
|
ufunc_T *func; ///< Function being called.
|
||||||
|
int linenr; ///< Next line to be executed.
|
||||||
|
int returned; ///< ":return" used.
|
||||||
|
/// Fixed variables for arguments.
|
||||||
|
TV_DICTITEM_STRUCT(VAR_SHORT_LEN + 1) fixvar[FIXVAR_CNT];
|
||||||
|
dict_T l_vars; ///< l: local function variables.
|
||||||
|
ScopeDictDictItem l_vars_var; ///< Variable for l: scope.
|
||||||
|
dict_T l_avars; ///< a: argument variables.
|
||||||
|
ScopeDictDictItem l_avars_var; ///< Variable for a: scope.
|
||||||
|
list_T l_varlist; ///< List for a:000.
|
||||||
|
listitem_T l_listitems[MAX_FUNC_ARGS]; ///< List items for a:000.
|
||||||
|
typval_T *rettv; ///< Return value.
|
||||||
|
linenr_T breakpoint; ///< Next line with breakpoint or zero.
|
||||||
|
int dbg_tick; ///< Debug_tick when breakpoint was set.
|
||||||
|
int level; ///< Top nesting level of executed function.
|
||||||
|
proftime_T prof_child; ///< Time spent in a child.
|
||||||
|
funccall_T *caller; ///< Calling function or NULL.
|
||||||
|
int fc_refcount; ///< Number of user functions that reference this funccall.
|
||||||
|
int fc_copyID; ///< CopyID used for garbage collection.
|
||||||
|
garray_T fc_funcs; ///< List of ufunc_T* which keep a reference to "func".
|
||||||
|
};
|
||||||
|
|
||||||
/// Structure to hold info for a user function.
|
/// Structure to hold info for a user function.
|
||||||
struct ufunc {
|
struct ufunc {
|
||||||
int uf_varargs; ///< variable nr of arguments
|
int uf_varargs; ///< variable nr of arguments
|
||||||
@@ -293,9 +323,6 @@ struct ufunc {
|
|||||||
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
|
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Maximum number of function arguments
|
|
||||||
#define MAX_FUNC_ARGS 20
|
|
||||||
|
|
||||||
struct partial_S {
|
struct partial_S {
|
||||||
int pt_refcount; ///< Reference count.
|
int pt_refcount; ///< Reference count.
|
||||||
char_u *pt_name; ///< Function name; when NULL use pt_func->name.
|
char_u *pt_name; ///< Function name; when NULL use pt_func->name.
|
||||||
|
3374
src/nvim/eval/userfunc.c
Normal file
3374
src/nvim/eval/userfunc.c
Normal file
File diff suppressed because it is too large
Load Diff
36
src/nvim/eval/userfunc.h
Normal file
36
src/nvim/eval/userfunc.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef NVIM_EVAL_USERFUNC_H
|
||||||
|
#define NVIM_EVAL_USERFUNC_H
|
||||||
|
|
||||||
|
#include "nvim/eval/typval.h"
|
||||||
|
#include "nvim/ex_cmds_defs.h"
|
||||||
|
|
||||||
|
///< Structure used by trans_function_name()
|
||||||
|
typedef struct {
|
||||||
|
dict_T *fd_dict; ///< Dictionary used.
|
||||||
|
char_u *fd_newkey; ///< New key in "dict" in allocated memory.
|
||||||
|
dictitem_T *fd_di; ///< Dictionary item used.
|
||||||
|
} funcdict_T;
|
||||||
|
|
||||||
|
/// errors for when calling a function
|
||||||
|
typedef enum {
|
||||||
|
ERROR_UNKNOWN = 0,
|
||||||
|
ERROR_TOOMANY,
|
||||||
|
ERROR_TOOFEW,
|
||||||
|
ERROR_SCRIPT,
|
||||||
|
ERROR_DICT,
|
||||||
|
ERROR_NONE,
|
||||||
|
ERROR_OTHER,
|
||||||
|
ERROR_BOTH,
|
||||||
|
ERROR_DELETED,
|
||||||
|
} FnameTransError;
|
||||||
|
|
||||||
|
typedef int (*ArgvFunc)(int current_argcount, typval_T *argv, int argskip,
|
||||||
|
int called_func_argcount);
|
||||||
|
|
||||||
|
#define FUNCARG(fp, j) ((char_u **)(fp->uf_args.ga_data))[j]
|
||||||
|
#define FUNCLINE(fp, j) ((char_u **)(fp->uf_lines.ga_data))[j]
|
||||||
|
|
||||||
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
# include "eval/userfunc.h.generated.h"
|
||||||
|
#endif
|
||||||
|
#endif // NVIM_EVAL_USERFUNC_H
|
@@ -20,7 +20,7 @@
|
|||||||
#include "nvim/buffer.h"
|
#include "nvim/buffer.h"
|
||||||
#include "nvim/change.h"
|
#include "nvim/change.h"
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds.h"
|
#include "nvim/ex_cmds.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/ex_eval.h"
|
#include "nvim/ex_eval.h"
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "nvim/digraph.h"
|
#include "nvim/digraph.h"
|
||||||
#include "nvim/edit.h"
|
#include "nvim/edit.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds.h"
|
#include "nvim/ex_cmds.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
#include "nvim/ex_eval.h"
|
#include "nvim/ex_eval.h"
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#include "nvim/ex_eval.h"
|
#include "nvim/ex_eval.h"
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/message.h"
|
#include "nvim/message.h"
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "nvim/digraph.h"
|
#include "nvim/digraph.h"
|
||||||
#include "nvim/edit.h"
|
#include "nvim/edit.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds.h"
|
#include "nvim/ex_cmds.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "nvim/cursor.h"
|
#include "nvim/cursor.h"
|
||||||
#include "nvim/diff.h"
|
#include "nvim/diff.h"
|
||||||
#include "nvim/edit.h"
|
#include "nvim/edit.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds.h"
|
#include "nvim/ex_cmds.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/ex_eval.h"
|
#include "nvim/ex_eval.h"
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "nvim/undo.h"
|
#include "nvim/undo.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/change.h"
|
#include "nvim/change.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#include "nvim/diff.h"
|
#include "nvim/diff.h"
|
||||||
#include "nvim/digraph.h"
|
#include "nvim/digraph.h"
|
||||||
#include "nvim/edit.h"
|
#include "nvim/edit.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds.h"
|
#include "nvim/ex_cmds.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
|
@@ -56,6 +56,7 @@
|
|||||||
#include "nvim/regexp.h"
|
#include "nvim/regexp.h"
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
|
@@ -248,6 +248,9 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
|
|||||||
|
|
||||||
# define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
|
# define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
|
||||||
|
|
||||||
|
// Character used as separated in autoload function/variable names.
|
||||||
|
#define AUTOLOAD_CHAR '#'
|
||||||
|
|
||||||
#include "nvim/message.h"
|
#include "nvim/message.h"
|
||||||
|
|
||||||
// Prefer using emsgf(), because perror() may send the output to the wrong
|
// Prefer using emsgf(), because perror() may send the output to the wrong
|
||||||
@@ -257,6 +260,8 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
|
|||||||
#define SHOWCMD_COLS 10 // columns needed by shown command
|
#define SHOWCMD_COLS 10 // columns needed by shown command
|
||||||
#define STL_MAX_ITEM 80 // max nr of %<flag> in statusline
|
#define STL_MAX_ITEM 80 // max nr of %<flag> in statusline
|
||||||
|
|
||||||
|
#include "nvim/path.h"
|
||||||
|
|
||||||
/// Compare file names
|
/// Compare file names
|
||||||
///
|
///
|
||||||
/// On some systems case in a file name does not matter, on others it does.
|
/// On some systems case in a file name does not matter, on others it does.
|
||||||
|
@@ -133,9 +133,6 @@ typedef enum {
|
|||||||
# include "viml/parser/expressions.c.generated.h"
|
# include "viml/parser/expressions.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Character used as a separator in autoload function/variable names.
|
|
||||||
#define AUTOLOAD_CHAR '#'
|
|
||||||
|
|
||||||
/// Scale number by a given factor
|
/// Scale number by a given factor
|
||||||
///
|
///
|
||||||
/// Used to apply exponent to a number. Idea taken from uClibc.
|
/// Used to apply exponent to a number. Idea taken from uClibc.
|
||||||
|
Reference in New Issue
Block a user