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.
diff --git a/src/vim9.h b/src/vim9.h
index b32dbea..22a3f39 100644
--- a/src/vim9.h
+++ b/src/vim9.h
@@ -113,6 +113,7 @@
ISN_FUNCREF, // push a function ref to dfunc isn_arg.funcref
ISN_NEWFUNC, // create a global function from a lambda function
ISN_DEF, // list functions
+ ISN_DEFER, // :defer argument count is isn_arg.number
// expression operations
ISN_JUMP, // jump if condition is matched isn_arg.jump
@@ -419,6 +420,12 @@
int dbg_break_lnum; // first line to break after
} debug_T;
+// arguments to ISN_DEFER
+typedef struct {
+ int defer_var_idx; // local variable index for defer list
+ int defer_argcount; // number of arguments
+} deferins_T;
+
/*
* Instruction
*/
@@ -468,6 +475,7 @@
tobool_T tobool;
getitem_T getitem;
debug_T debug;
+ deferins_T defer;
} isn_arg;
};
@@ -498,6 +506,9 @@
int df_varcount; // number of local variables
int df_has_closure; // one if a closure was created
+ int df_defer_var_idx; // index of local variable that has a list
+ // of deferred function calls; zero if not
+ // set
};
// Number of entries used by stack frame for a function call.
@@ -735,6 +746,15 @@
// lhs_name is not NULL
};
+/*
+ * List of special functions for "compile_arguments()".
+ */
+typedef enum {
+ CA_NOT_SPECIAL,
+ CA_SEARCHPAIR, // {skip} in searchpair() and searchpairpos()
+ CA_SUBSTITUTE, // {sub} in substitute(), when prefixed with \=
+} ca_special_T;
+
// flags for typval2type()
#define TVTT_DO_MEMBER 1
#define TVTT_MORE_SPECIFIC 2 // get most specific type for member