comparison src/vim9.h @ 30065:6cf788ab844c v9.0.0370

patch 9.0.0370: cleaning up afterwards can make a function messy Commit: https://github.com/vim/vim/commit/1d84f7608f1e41dad03b8cc7925895437775f7c0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 3 21:35:53 2022 +0100 patch 9.0.0370: cleaning up afterwards can make a function messy Problem: Cleaning up afterwards can make a function messy. Solution: Add the :defer command.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Sep 2022 22:45:03 +0200
parents d269dd3cd31d
children 6575d0bf6061
comparison
equal deleted inserted replaced
30064:a8f1fbaa43c8 30065:6cf788ab844c
111 ISN_RETURN, // return, result is on top of stack 111 ISN_RETURN, // return, result is on top of stack
112 ISN_RETURN_VOID, // Push void, then return 112 ISN_RETURN_VOID, // Push void, then return
113 ISN_FUNCREF, // push a function ref to dfunc isn_arg.funcref 113 ISN_FUNCREF, // push a function ref to dfunc isn_arg.funcref
114 ISN_NEWFUNC, // create a global function from a lambda function 114 ISN_NEWFUNC, // create a global function from a lambda function
115 ISN_DEF, // list functions 115 ISN_DEF, // list functions
116 ISN_DEFER, // :defer argument count is isn_arg.number
116 117
117 // expression operations 118 // expression operations
118 ISN_JUMP, // jump if condition is matched isn_arg.jump 119 ISN_JUMP, // jump if condition is matched isn_arg.jump
119 ISN_JUMP_IF_ARG_SET, // jump if argument is already set, uses 120 ISN_JUMP_IF_ARG_SET, // jump if argument is already set, uses
120 // isn_arg.jumparg 121 // isn_arg.jumparg
416 // arguments to ISN_DEBUG 417 // arguments to ISN_DEBUG
417 typedef struct { 418 typedef struct {
418 varnumber_T dbg_var_names_len; // current number of local variables 419 varnumber_T dbg_var_names_len; // current number of local variables
419 int dbg_break_lnum; // first line to break after 420 int dbg_break_lnum; // first line to break after
420 } debug_T; 421 } debug_T;
422
423 // arguments to ISN_DEFER
424 typedef struct {
425 int defer_var_idx; // local variable index for defer list
426 int defer_argcount; // number of arguments
427 } deferins_T;
421 428
422 /* 429 /*
423 * Instruction 430 * Instruction
424 */ 431 */
425 struct isn_S { 432 struct isn_S {
466 isn_T *instr; 473 isn_T *instr;
467 tostring_T tostring; 474 tostring_T tostring;
468 tobool_T tobool; 475 tobool_T tobool;
469 getitem_T getitem; 476 getitem_T getitem;
470 debug_T debug; 477 debug_T debug;
478 deferins_T defer;
471 } isn_arg; 479 } isn_arg;
472 }; 480 };
473 481
474 /* 482 /*
475 * Info about a function defined with :def. Used in "def_functions". 483 * Info about a function defined with :def. Used in "def_functions".
496 int df_instr_prof_count; // size of "df_instr_prof" 504 int df_instr_prof_count; // size of "df_instr_prof"
497 #endif 505 #endif
498 506
499 int df_varcount; // number of local variables 507 int df_varcount; // number of local variables
500 int df_has_closure; // one if a closure was created 508 int df_has_closure; // one if a closure was created
509 int df_defer_var_idx; // index of local variable that has a list
510 // of deferred function calls; zero if not
511 // set
501 }; 512 };
502 513
503 // Number of entries used by stack frame for a function call. 514 // Number of entries used by stack frame for a function call.
504 // - ec_dfunc_idx: function index 515 // - ec_dfunc_idx: function index
505 // - ec_iidx: instruction index 516 // - ec_iidx: instruction index
733 744
734 lhs_T ctx_redir_lhs; // LHS for ":redir => var", valid when 745 lhs_T ctx_redir_lhs; // LHS for ":redir => var", valid when
735 // lhs_name is not NULL 746 // lhs_name is not NULL
736 }; 747 };
737 748
749 /*
750 * List of special functions for "compile_arguments()".
751 */
752 typedef enum {
753 CA_NOT_SPECIAL,
754 CA_SEARCHPAIR, // {skip} in searchpair() and searchpairpos()
755 CA_SUBSTITUTE, // {sub} in substitute(), when prefixed with \=
756 } ca_special_T;
757
738 // flags for typval2type() 758 // flags for typval2type()
739 #define TVTT_DO_MEMBER 1 759 #define TVTT_DO_MEMBER 1
740 #define TVTT_MORE_SPECIFIC 2 // get most specific type for member 760 #define TVTT_MORE_SPECIFIC 2 // get most specific type for member
741 761