Mercurial > vim
comparison src/structs.h @ 30291:61a688be1899 v9.0.0481
patch 9.0.0481: in :def function all closures in loop get the same variables
Commit: https://github.com/vim/vim/commit/8fa745e7be3a791ac25f93ef0227bbc48ade8a37
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 16 19:04:24 2022 +0100
patch 9.0.0481: in :def function all closures in loop get the same variables
Problem: In a :def function all closures in a loop get the same variables.
Solution: Use a separate list of variables for LOADOUTER and STOREOUTER.
Not copied at end of loop yet.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Sep 2022 20:15:03 +0200 |
parents | d3cfd12839ef |
children | 5c181bb6c855 |
comparison
equal
deleted
inserted
replaced
30290:e5d24015e8c5 | 30291:61a688be1899 |
---|---|
1654 UF_COMPILE_ERROR // compilation error, cannot execute | 1654 UF_COMPILE_ERROR // compilation error, cannot execute |
1655 } def_status_T; | 1655 } def_status_T; |
1656 | 1656 |
1657 /* | 1657 /* |
1658 * Structure to hold info for a user function. | 1658 * Structure to hold info for a user function. |
1659 * When adding a field check copy_func(). | 1659 * When adding a field check copy_lambda_to_global_func(). |
1660 */ | 1660 */ |
1661 typedef struct | 1661 typedef struct |
1662 { | 1662 { |
1663 int uf_varargs; // variable nr of arguments (old style) | 1663 int uf_varargs; // variable nr of arguments (old style) |
1664 int uf_flags; // FC_ flags | 1664 int uf_flags; // FC_ flags |
1739 #define FC_DEAD 0x80 // function kept only for reference to dfunc | 1739 #define FC_DEAD 0x80 // function kept only for reference to dfunc |
1740 #define FC_EXPORT 0x100 // "export def Func()" | 1740 #define FC_EXPORT 0x100 // "export def Func()" |
1741 #define FC_NOARGS 0x200 // no a: variables in lambda | 1741 #define FC_NOARGS 0x200 // no a: variables in lambda |
1742 #define FC_VIM9 0x400 // defined in vim9 script file | 1742 #define FC_VIM9 0x400 // defined in vim9 script file |
1743 #define FC_CFUNC 0x800 // defined as Lua C func | 1743 #define FC_CFUNC 0x800 // defined as Lua C func |
1744 #define FC_COPY 0x1000 // copy of another function by copy_func() | 1744 #define FC_COPY 0x1000 // copy of another function by |
1745 // copy_lambda_to_global_func() | |
1745 #define FC_LAMBDA 0x2000 // one line "return {expr}" | 1746 #define FC_LAMBDA 0x2000 // one line "return {expr}" |
1746 | 1747 |
1747 #define MAX_FUNC_ARGS 20 // maximum number of function arguments | 1748 #define MAX_FUNC_ARGS 20 // maximum number of function arguments |
1748 #define VAR_SHORT_LEN 20 // short variable name length | 1749 #define VAR_SHORT_LEN 20 // short variable name length |
1749 #define FIXVAR_CNT 12 // number of fixed variables | 1750 #define FIXVAR_CNT 12 // number of fixed variables |
2094 int fs_copyID; // for garray_T collection | 2095 int fs_copyID; // for garray_T collection |
2095 }; | 2096 }; |
2096 | 2097 |
2097 typedef struct outer_S outer_T; | 2098 typedef struct outer_S outer_T; |
2098 struct outer_S { | 2099 struct outer_S { |
2099 garray_T *out_stack; // stack from outer scope | 2100 garray_T *out_stack; // stack from outer scope, or a copy |
2101 // containing only arguments and local vars | |
2100 int out_frame_idx; // index of stack frame in out_stack | 2102 int out_frame_idx; // index of stack frame in out_stack |
2101 outer_T *out_up; // outer scope of outer scope or NULL | 2103 outer_T *out_up; // outer scope of outer scope or NULL |
2102 partial_T *out_up_partial; // partial owning out_up or NULL | 2104 partial_T *out_up_partial; // partial owning out_up or NULL |
2105 | |
2106 garray_T *out_loop_stack; // stack from outer scope, or a copy | |
2107 // containing only vars inside the loop | |
2108 short out_loop_var_idx; // first variable defined in a loop | |
2109 // in out_loop_stack | |
2110 short out_loop_var_count; // number of variables defined in a loop | |
2103 }; | 2111 }; |
2104 | 2112 |
2105 struct partial_S | 2113 struct partial_S |
2106 { | 2114 { |
2107 int pt_refcount; // reference count | 2115 int pt_refcount; // reference count |