Mercurial > vim
comparison src/vim9cmds.c @ 33587:c470d4fd5eba v9.0.2038
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Commit: https://github.com/vim/vim/commit/f3eac695bfe3453fe2a8b980601c55835406f14b
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Oct 17 11:00:45 2023 +0200
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Problem: Vim9: object method funcref not cleaned up after use
Solution: Clean up type stack after using object method funcref,
remove now longer used ISN_DEFEROBJ instrunction
closes: #13360
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 17 Oct 2023 11:15:06 +0200 |
parents | f61713271934 |
children | bdd408288d95 |
comparison
equal
deleted
inserted
replaced
33586:fd76c227e266 | 33587:c470d4fd5eba |
---|---|
1998 char_u *arg = arg_start; | 1998 char_u *arg = arg_start; |
1999 int argcount = 0; | 1999 int argcount = 0; |
2000 int defer_var_idx; | 2000 int defer_var_idx; |
2001 type_T *type; | 2001 type_T *type; |
2002 int func_idx; | 2002 int func_idx; |
2003 int obj_method = 0; | |
2004 | 2003 |
2005 // Get a funcref for the function name. | 2004 // Get a funcref for the function name. |
2006 // TODO: better way to find the "(". | 2005 // TODO: better way to find the "(". |
2007 paren = vim_strchr(arg, '('); | 2006 paren = vim_strchr(arg, '('); |
2008 if (paren == NULL) | 2007 if (paren == NULL) |
2014 func_idx = find_internal_func(arg); | 2013 func_idx = find_internal_func(arg); |
2015 if (func_idx >= 0) | 2014 if (func_idx >= 0) |
2016 // TODO: better type | 2015 // TODO: better type |
2017 generate_PUSHFUNC(cctx, (char_u *)internal_func_name(func_idx), | 2016 generate_PUSHFUNC(cctx, (char_u *)internal_func_name(func_idx), |
2018 &t_func_any, FALSE); | 2017 &t_func_any, FALSE); |
2019 else | 2018 else if (compile_expr0(&arg, cctx) == FAIL) |
2020 { | 2019 return NULL; |
2021 int typecount = cctx->ctx_type_stack.ga_len; | |
2022 if (compile_expr0(&arg, cctx) == FAIL) | |
2023 return NULL; | |
2024 if (cctx->ctx_type_stack.ga_len >= typecount + 2) | |
2025 // must have seen "obj.Func", pushed an object and a function | |
2026 obj_method = 1; | |
2027 } | |
2028 *paren = '('; | 2020 *paren = '('; |
2029 | 2021 |
2030 // check for function type | 2022 // check for function type |
2031 type = get_type_on_stack(cctx, 0); | 2023 type = get_type_on_stack(cctx, 0); |
2032 if (type->tt_type != VAR_FUNC) | 2024 if (type->tt_type != VAR_FUNC) |
2054 return NULL; | 2046 return NULL; |
2055 | 2047 |
2056 defer_var_idx = get_defer_var_idx(cctx); | 2048 defer_var_idx = get_defer_var_idx(cctx); |
2057 if (defer_var_idx == 0) | 2049 if (defer_var_idx == 0) |
2058 return NULL; | 2050 return NULL; |
2059 if (generate_DEFER(cctx, defer_var_idx - 1, obj_method, argcount) == FAIL) | 2051 if (generate_DEFER(cctx, defer_var_idx - 1, argcount) == FAIL) |
2060 return NULL; | 2052 return NULL; |
2061 | 2053 |
2062 return skipwhite(arg); | 2054 return skipwhite(arg); |
2063 } | 2055 } |
2064 | 2056 |