Patch 9.0.0549

5 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 22, 2022, 12:34:42 PM9/22/22
to vim...@googlegroups.com

Patch 9.0.0549
Problem: Duplicated code in calling a :def function.
Solution: Simplify the code.
Files: src/vim9execute.c


*** ../vim-9.0.0548/src/vim9execute.c 2022-09-22 16:36:21.912930258 +0100
--- src/vim9execute.c 2022-09-22 17:32:55.742741076 +0100
***************
*** 380,386 ****
* Call compiled function "cdf_idx" from compiled code.
* This adds a stack frame and sets the instruction pointer to the start of the
* called function.
! * If "pt" is not null use "pt->pt_outer" for ec_outer_ref->or_outer.
*
* Stack has:
* - current arguments (already there)
--- 380,386 ----
* Call compiled function "cdf_idx" from compiled code.
* This adds a stack frame and sets the instruction pointer to the start of the
* called function.
! * If "pt_arg" is not NULL use "pt_arg->pt_outer" for ec_outer_ref->or_outer.
*
* Stack has:
* - current arguments (already there)
***************
*** 394,400 ****
static int
call_dfunc(
int cdf_idx,
! partial_T *pt,
int argcount_arg,
ectx_T *ectx)
{
--- 394,400 ----
static int
call_dfunc(
int cdf_idx,
! partial_T *pt_arg,
int argcount_arg,
ectx_T *ectx)
{
***************
*** 543,569 ****
STACK_TV_BOT(STACK_FRAME_IDX_OFF)->vval.v_number = ectx->ec_frame_idx;
ectx->ec_frame_idx = ectx->ec_stack.ga_len;

! // Initialize local variables
! for (idx = 0; idx < dfunc->df_varcount; ++idx)
{
typval_T *tv = STACK_TV_BOT(STACK_FRAME_SIZE + idx);

tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
}
- if (dfunc->df_has_closure)
- {
- typval_T *tv = STACK_TV_BOT(STACK_FRAME_SIZE + dfunc->df_varcount);
-
- // Initialize the variable that counts how many closures were created.
- // This is used in handle_closure_in_use().
- tv->v_type = VAR_NUMBER;
- tv->vval.v_number = 0;
- }
ectx->ec_stack.ga_len += STACK_FRAME_SIZE + varcount;

! if (pt != NULL || ufunc->uf_partial != NULL
! || (ufunc->uf_flags & FC_CLOSURE))
{
outer_ref_T *ref = ALLOC_CLEAR_ONE(outer_ref_T);

--- 543,563 ----
STACK_TV_BOT(STACK_FRAME_IDX_OFF)->vval.v_number = ectx->ec_frame_idx;
ectx->ec_frame_idx = ectx->ec_stack.ga_len;

! // Initialize all local variables to number zero. Also initialize the
! // variable that counts how many closures were created. This is used in
! // handle_closure_in_use().
! int initcount = dfunc->df_varcount + (dfunc->df_has_closure ? 1 : 0);
! for (idx = 0; idx < initcount; ++idx)
{
typval_T *tv = STACK_TV_BOT(STACK_FRAME_SIZE + idx);

tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
}
ectx->ec_stack.ga_len += STACK_FRAME_SIZE + varcount;

! partial_T *pt = pt_arg != NULL ? pt_arg : ufunc->uf_partial;
! if (pt != NULL || (ufunc->uf_flags & FC_CLOSURE))
{
outer_ref_T *ref = ALLOC_CLEAR_ONE(outer_ref_T);

***************
*** 575,586 ****
++pt->pt_refcount;
ref->or_partial = pt;
}
- else if (ufunc->uf_partial != NULL)
- {
- ref->or_outer = get_pt_outer(ufunc->uf_partial);
- ++ufunc->uf_partial->pt_refcount;
- ref->or_partial = ufunc->uf_partial;
- }
else
{
ref->or_outer = ALLOC_CLEAR_ONE(outer_T);
--- 569,574 ----
***************
*** 5832,5838 ****
ectx.ec_where.wt_index = 0;
ectx.ec_where.wt_variable = FALSE;

! // Execute the instructions until done.
ret = exec_instructions(&ectx);
if (ret == OK)
{
--- 5820,5828 ----
ectx.ec_where.wt_index = 0;
ectx.ec_where.wt_variable = FALSE;

! /*
! * Execute the instructions until done.
! */
ret = exec_instructions(&ectx);
if (ret == OK)
{
*** ../vim-9.0.0548/src/version.c 2022-09-22 17:06:56.299037474 +0100
--- src/version.c 2022-09-22 17:32:13.842794133 +0100
***************
*** 701,702 ****
--- 701,704 ----
{ /* Add new patch number below this line */
+ /**/
+ 549,
/**/

--
Birthdays are healthy. The more you have them, the longer you live.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages