Macros | Functions
ex_eval.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include "nvim/ascii.h"
#include "nvim/charset.h"
#include "nvim/debugger.h"
#include "nvim/eval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/regexp.h"
#include "nvim/strings.h"
#include "nvim/vim.h"

Macros

#define THROW_ON_ERROR   true
 
#define THROW_ON_ERROR_TRUE
 
#define THROW_ON_INTERRUPT   true
 
#define THROW_ON_INTERRUPT_TRUE
 
#define CHECK_SKIP
 
#define RP_MAKE   0
 
#define RP_RESUME   1
 
#define RP_DISCARD   2
 

Functions

int aborting (void)
 
void update_force_abort (void)
 
int should_abort (int retcode)
 
int aborted_in_try (void)
 
bool cause_errthrow (const char *mesg, bool severe, bool *ignore) FUNC_ATTR_NONNULL_ALL
 
void free_global_msglist (void)
 
void do_errthrow (cstack_T *cstack, char *cmdname)
 
int do_intthrow (cstack_T *cstack)
 
char * get_exception_string (void *value, except_type_T type, char *cmdname, int *should_free)
 Get an exception message that is to be stored in current_exception->value. More...
 
void discard_current_exception (void)
 Discard the exception currently being thrown. More...
 
void report_make_pending (int pending, void *value)
 
void report_resume_pending (int pending, void *value)
 
void report_discard_pending (int pending, void *value)
 
void ex_eval (exarg_T *eap)
 Handle ":eval". More...
 
void ex_if (exarg_T *eap)
 Handle ":if". More...
 
void ex_endif (exarg_T *eap)
 Handle ":endif". More...
 
void ex_else (exarg_T *eap)
 Handle ":else" and ":elseif". More...
 
void ex_while (exarg_T *eap)
 Handle ":while" and ":for". More...
 
void ex_continue (exarg_T *eap)
 Handle ":continue". More...
 
void ex_break (exarg_T *eap)
 Handle ":break". More...
 
void ex_endwhile (exarg_T *eap)
 Handle ":endwhile" and ":endfor". More...
 
void ex_throw (exarg_T *eap)
 Handle ":throw expr". More...
 
void do_throw (cstack_T *cstack)
 
void ex_try (exarg_T *eap)
 Handle ":try". More...
 
void ex_catch (exarg_T *eap)
 Handle ":catch /{pattern}/" and ":catch". More...
 
void ex_finally (exarg_T *eap)
 Handle ":finally". More...
 
void ex_endtry (exarg_T *eap)
 Handle ":endtry". More...
 
void enter_cleanup (cleanup_T *csp)
 
void leave_cleanup (cleanup_T *csp)
 
int cleanup_conditionals (cstack_T *cstack, int searched_cond, int inclusive)
 
void rewind_conditionals (cstack_T *cstack, int idx, int cond_type, int *cond_level)
 
void ex_endfunction (exarg_T *eap)
 Handle ":endfunction" when not after a ":function". More...
 
int has_loop_cmd (char *p)
 

Detailed Description

Functions for Ex command line for the +eval feature.

Macro Definition Documentation

◆ CHECK_SKIP

#define CHECK_SKIP
Value:
|| got_int \
|| (cstack->cs_idx > 0 \
&& !(cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE)))

◆ RP_DISCARD

#define RP_DISCARD   2

◆ RP_MAKE

#define RP_MAKE   0

◆ RP_RESUME

#define RP_RESUME   1

◆ THROW_ON_ERROR

#define THROW_ON_ERROR   true

◆ THROW_ON_ERROR_TRUE

#define THROW_ON_ERROR_TRUE

◆ THROW_ON_INTERRUPT

#define THROW_ON_INTERRUPT   true

◆ THROW_ON_INTERRUPT_TRUE

#define THROW_ON_INTERRUPT_TRUE

Function Documentation

◆ aborted_in_try()

int aborted_in_try ( void  )
Returns
TRUE if a function with the "abort" flag should not be considered ended on an error. This means that parsing commands is continued in order to find finally clauses to be executed, and that some errors in skipped commands are still reported.

◆ aborting()

int aborting ( void  )
Returns
true when immediately aborting on error, or when an interrupt occurred or an exception was thrown but not caught.

Use for ":{range}call" to check whether an aborted function that does not handle a range itself should be called again for the next line in the range. Also used for cancelling expression evaluation after a function call caused an immediate abort. Note that the first emsg() call temporarily resets "force_abort" until the throw point for error messages has been reached. That is, during cancellation of an expression evaluation after an aborting function call or due to a parsing error, aborting() always returns the same value. "got_int" is also set by calling interrupt().

◆ cause_errthrow()

bool cause_errthrow ( const char *  mesg,
bool  severe,
bool ignore 
)

cause_errthrow(): Cause a throw of an error exception if appropriate.

Returns
true if the error message should not be displayed by emsg().

Sets "ignore", if the emsg() call should be ignored completely.

When several messages appear in the same command, the first is usually the most specific one and used as the exception value. The "severe" flag can be set to true, if a later but severer message should be used instead.

◆ cleanup_conditionals()

int cleanup_conditionals ( cstack_T cstack,
int  searched_cond,
int  inclusive 
)

Make conditionals inactive and discard what's pending in finally clauses until the conditional type searched for or a try conditional not in its finally clause is reached. If this is in an active catch clause, finish the caught exception.

Parameters
searched_condPossible values are (CSF_WHILE | CSF_FOR) or CSF_TRY or 0, the latter meaning the innermost try conditional not in its finally clause.
inclusivetells whether the conditional searched for should be made inactive itself (a try conditional not in its finally clause possibly find before is always made inactive).

If "inclusive" is TRUE and "searched_cond" is CSF_TRY|CSF_SILENT, the saved former value of "emsg_silent", if reset when the try conditional finally reached was entered, is restored (used by ex_endtry()). This is normally done only when such a try conditional is left.

Returns
the cstack index where the search stopped.

◆ discard_current_exception()

void discard_current_exception ( void  )

Discard the exception currently being thrown.

◆ do_errthrow()

void do_errthrow ( cstack_T cstack,
char *  cmdname 
)

Throw the message specified in the call to cause_errthrow() above as an error exception. If cstack is NULL, postpone the throw until do_cmdline() has returned (see do_one_cmd()).

◆ do_intthrow()

int do_intthrow ( cstack_T cstack)

do_intthrow(): Replace the current exception by an interrupt or interrupt exception if appropriate.

Returns
TRUE if the current exception is discarded or, FALSE otherwise.

◆ do_throw()

void do_throw ( cstack_T cstack)

Throw the current exception through the specified cstack. Common routine for ":throw" (user exception) and error and interrupt exceptions. Also used for rethrowing an uncaught exception.

◆ enter_cleanup()

void enter_cleanup ( cleanup_T csp)

This function works a bit like ex_finally() except that there was not actually an extra try block around the part that failed and an error or interrupt has not (yet) been converted to an exception. This function saves the error/interrupt/ exception state and prepares for the call to do_cmdline() that is going to be made for the cleanup autocommand execution.

◆ ex_break()

void ex_break ( exarg_T eap)

Handle ":break".

◆ ex_catch()

void ex_catch ( exarg_T eap)

Handle ":catch /{pattern}/" and ":catch".

◆ ex_continue()

void ex_continue ( exarg_T eap)

Handle ":continue".

◆ ex_else()

void ex_else ( exarg_T eap)

Handle ":else" and ":elseif".

◆ ex_endfunction()

void ex_endfunction ( exarg_T eap)

Handle ":endfunction" when not after a ":function".

◆ ex_endif()

void ex_endif ( exarg_T eap)

Handle ":endif".

◆ ex_endtry()

void ex_endtry ( exarg_T eap)

Handle ":endtry".

◆ ex_endwhile()

void ex_endwhile ( exarg_T eap)

Handle ":endwhile" and ":endfor".

◆ ex_eval()

void ex_eval ( exarg_T eap)

Handle ":eval".

◆ ex_finally()

void ex_finally ( exarg_T eap)

Handle ":finally".

◆ ex_if()

void ex_if ( exarg_T eap)

Handle ":if".

◆ ex_throw()

void ex_throw ( exarg_T eap)

Handle ":throw expr".

◆ ex_try()

void ex_try ( exarg_T eap)

Handle ":try".

◆ ex_while()

void ex_while ( exarg_T eap)

Handle ":while" and ":for".

◆ free_global_msglist()

void free_global_msglist ( void  )

Free global "*msg_list" and the messages it contains, then set "*msg_list" to NULL.

◆ get_exception_string()

char* get_exception_string ( void value,
except_type_T  type,
char *  cmdname,
int *  should_free 
)

Get an exception message that is to be stored in current_exception->value.

◆ has_loop_cmd()

int has_loop_cmd ( char *  p)
Returns
TRUE if the string "p" looks like a ":while" or ":for" command.

◆ leave_cleanup()

void leave_cleanup ( cleanup_T csp)

This function is a bit like ex_endtry() except that there was not actually an extra try block around the part that failed and an error or interrupt had not (yet) been converted to an exception when the cleanup autocommand sequence was invoked.

See comment above enter_cleanup() for how this function is used.

This function has to be called with the address of the cleanup_T structure filled by enter_cleanup() as an argument; it restores the error/interrupt/ exception state saved by that function - except there was an aborting error, an interrupt or an uncaught exception during execution of the cleanup autocommands. In the latter case, the saved error/interrupt/ exception state is discarded.

◆ report_discard_pending()

void report_discard_pending ( int  pending,
void value 
)

If something pending in a finally clause is discarded, report it if required by the 'verbose' option or when debugging.

◆ report_make_pending()

void report_make_pending ( int  pending,
void value 
)

If something is made pending in a finally clause, report it if required by the 'verbose' option or when debugging.

◆ report_resume_pending()

void report_resume_pending ( int  pending,
void value 
)

If something pending in a finally clause is resumed at the ":endtry", report it if required by the 'verbose' option or when debugging.

◆ rewind_conditionals()

void rewind_conditionals ( cstack_T cstack,
int  idx,
int  cond_type,
int *  cond_level 
)

Rewind conditionals until index "idx" is reached. "cond_type" and "cond_level" specify a conditional type and the address of a level variable which is to be decremented with each skipped conditional of the specified type. Also free "for info" structures where needed.

◆ should_abort()

int should_abort ( int  retcode)
Returns
TRUE if a command with a subcommand resulting in "retcode" should abort the script processing. Can be used to suppress an autocommand after execution of a failing subcommand as long as the error message has not been displayed and actually caused the abortion.

◆ update_force_abort()

void update_force_abort ( void  )

The value of "force_abort" is temporarily reset by the first emsg() call during an expression evaluation, and "cause_abort" is used instead. It might be necessary to restore "force_abort" even before the throw point for the error message has been reached. update_force_abort() should be called then.

current_exception
EXTERN except_T * current_exception
Definition: globals.h:274
did_emsg
did_emsg
Definition: userfunc.c:1096
CSF_ACTIVE
#define CSF_ACTIVE
Definition: ex_eval.h:10