ex_eval.h
Go to the documentation of this file.
1 #ifndef NVIM_EX_EVAL_H
2 #define NVIM_EX_EVAL_H
3 
4 #include "nvim/ex_cmds_defs.h" // for exarg_T
5 #include "nvim/pos.h" // for linenr_T
6 
7 /* There is no CSF_IF, the lack of CSF_WHILE, CSF_FOR and CSF_TRY means ":if"
8  * was used. */
9 #define CSF_TRUE 0x0001 // condition was TRUE
10 #define CSF_ACTIVE 0x0002 // current state is active
11 #define CSF_ELSE 0x0004 // ":else" has been passed
12 #define CSF_WHILE 0x0008 // is a ":while"
13 #define CSF_FOR 0x0010 // is a ":for"
14 
15 #define CSF_TRY 0x0100 // is a ":try"
16 #define CSF_FINALLY 0x0200 // ":finally" has been passed
17 #define CSF_THROWN 0x0400 // exception thrown to this try conditional
18 #define CSF_CAUGHT 0x0800 // exception caught by this try conditional
19 #define CSF_SILENT 0x1000 // "emsg_silent" reset by ":try"
20 /* Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
21  * (an ":if"), and CSF_SILENT is only used when CSF_TRY is set. */
22 
23 /*
24  * What's pending for being reactivated at the ":endtry" of this try
25  * conditional:
26  */
27 #define CSTP_NONE 0 // nothing pending in ":finally" clause
28 #define CSTP_ERROR 1 // an error is pending
29 #define CSTP_INTERRUPT 2 // an interrupt is pending
30 #define CSTP_THROW 4 // a throw is pending
31 #define CSTP_BREAK 8 // ":break" is pending
32 #define CSTP_CONTINUE 16 // ":continue" is pending
33 #define CSTP_RETURN 24 // ":return" is pending
34 #define CSTP_FINISH 32 // ":finish" is pending
35 
36 /*
37  * A list of error messages that can be converted to an exception. "throw_msg"
38  * is only set in the first element of the list. Usually, it points to the
39  * original message stored in that element, but sometimes it points to a later
40  * message in the list. See cause_errthrow() below.
41  */
42 struct msglist {
43  char *msg; // original message
44  char *throw_msg; // msg to throw: usually original one
45  struct msglist *next; // next of several messages in a row
46 };
47 
48 // The exception types.
49 typedef enum
50 {
51  ET_USER, // exception caused by ":throw" command
52  ET_ERROR, // error exception
53  ET_INTERRUPT, // interrupt exception triggered by Ctrl-C
55 
56 /*
57  * Structure describing an exception.
58  * (don't use "struct exception", it's used by the math library).
59  */
60 typedef struct vim_exception except_T;
61 struct vim_exception {
62  except_type_T type; // exception type
63  char *value; // exception value
64  struct msglist *messages; // message(s) causing error exception
65  char_u *throw_name; // name of the throw point
66  linenr_T throw_lnum; // line number of the throw point
67  except_T *caught; // next exception on the caught stack
68 };
69 
70 /*
71  * Structure to save the error/interrupt/exception state between calls to
72  * enter_cleanup() and leave_cleanup(). Must be allocated as an automatic
73  * variable by the (common) caller of these functions.
74  */
75 typedef struct cleanup_stuff cleanup_T;
76 struct cleanup_stuff {
77  int pending; // error/interrupt/exception state
78  except_T *exception; // exception value
79 };
80 
81 #ifdef INCLUDE_GENERATED_DECLARATIONS
82 # include "ex_eval.h.generated.h"
83 #endif
84 #endif // NVIM_EX_EVAL_H
vim_exception::value
char * value
Definition: ex_eval.h:63
ET_ERROR
@ ET_ERROR
Definition: ex_eval.h:52
msglist::throw_msg
char * throw_msg
Definition: ex_eval.h:44
msglist
Definition: ex_eval.h:42
ET_INTERRUPT
@ ET_INTERRUPT
Definition: ex_eval.h:53
vim_exception::throw_lnum
linenr_T throw_lnum
Definition: ex_eval.h:66
msglist::next
struct msglist * next
Definition: ex_eval.h:45
vim_exception::caught
except_T * caught
Definition: ex_eval.h:67
cleanup_stuff
Definition: ex_eval.h:76
vim_exception::throw_name
char_u * throw_name
Definition: ex_eval.h:65
vim_exception::type
except_type_T type
Definition: ex_eval.h:62
msglist::msg
char * msg
Definition: ex_eval.h:43
vim_exception::messages
struct msglist * messages
Definition: ex_eval.h:64
except_type_T
except_type_T
Definition: ex_eval.h:49
cleanup_stuff::pending
int pending
Definition: ex_eval.h:77
ET_USER
@ ET_USER
Definition: ex_eval.h:51
char_u
unsigned char char_u
Definition: types.h:12
cleanup_stuff::exception
except_T * exception
Definition: ex_eval.h:78
ex_cmds_defs.h
linenr_T
long linenr_T
Definition: pos.h:7
vim_exception
Definition: ex_eval.h:61
pos.h