Mercurial > vim
comparison src/vim9execute.c @ 20433:5950284a517f v8.2.0771
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Commit: https://github.com/vim/vim/commit/6f5b6dfb16228c0ce1e4379b7bafed02eaddbab2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 16 21:20:12 2020 +0200
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Problem: Vim9: cannot call a compiled closure from not compiled code.
Solution: Pass funcexe to call_user_func().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 16 May 2020 21:30:10 +0200 |
parents | 0ab8f8880a33 |
children | 489cb75c76b6 |
comparison
equal
deleted
inserted
replaced
20432:05b26264315a | 20433:5950284a517f |
---|---|
639 int | 639 int |
640 call_def_function( | 640 call_def_function( |
641 ufunc_T *ufunc, | 641 ufunc_T *ufunc, |
642 int argc_arg, // nr of arguments | 642 int argc_arg, // nr of arguments |
643 typval_T *argv, // arguments | 643 typval_T *argv, // arguments |
644 partial_T *partial, // optional partial for context | |
644 typval_T *rettv) // return value | 645 typval_T *rettv) // return value |
645 { | 646 { |
646 ectx_T ectx; // execution context | 647 ectx_T ectx; // execution context |
647 int argc = argc_arg; | 648 int argc = argc_arg; |
648 int initial_frame_idx; | 649 int initial_frame_idx; |
717 ++ectx.ec_stack.ga_len; | 718 ++ectx.ec_stack.ga_len; |
718 | 719 |
719 // Frame pointer points to just after arguments. | 720 // Frame pointer points to just after arguments. |
720 ectx.ec_frame_idx = ectx.ec_stack.ga_len; | 721 ectx.ec_frame_idx = ectx.ec_stack.ga_len; |
721 initial_frame_idx = ectx.ec_frame_idx; | 722 initial_frame_idx = ectx.ec_frame_idx; |
723 | |
724 if (partial != NULL) | |
725 { | |
726 ectx.ec_outer_stack = partial->pt_ectx_stack; | |
727 ectx.ec_outer_frame = partial->pt_ectx_frame; | |
728 } | |
722 | 729 |
723 // dummy frame entries | 730 // dummy frame entries |
724 for (idx = 0; idx < STACK_FRAME_SIZE; ++idx) | 731 for (idx = 0; idx < STACK_FRAME_SIZE; ++idx) |
725 { | 732 { |
726 STACK_TV(ectx.ec_stack.ga_len)->v_type = VAR_UNKNOWN; | 733 STACK_TV(ectx.ec_stack.ga_len)->v_type = VAR_UNKNOWN; |
1466 // call a funcref or partial | 1473 // call a funcref or partial |
1467 case ISN_PCALL: | 1474 case ISN_PCALL: |
1468 { | 1475 { |
1469 cpfunc_T *pfunc = &iptr->isn_arg.pfunc; | 1476 cpfunc_T *pfunc = &iptr->isn_arg.pfunc; |
1470 int r; | 1477 int r; |
1471 typval_T partial; | 1478 typval_T partial_tv; |
1472 | 1479 |
1473 SOURCING_LNUM = iptr->isn_lnum; | 1480 SOURCING_LNUM = iptr->isn_lnum; |
1474 if (pfunc->cpf_top) | 1481 if (pfunc->cpf_top) |
1475 { | 1482 { |
1476 // funcref is above the arguments | 1483 // funcref is above the arguments |
1478 } | 1485 } |
1479 else | 1486 else |
1480 { | 1487 { |
1481 // Get the funcref from the stack. | 1488 // Get the funcref from the stack. |
1482 --ectx.ec_stack.ga_len; | 1489 --ectx.ec_stack.ga_len; |
1483 partial = *STACK_TV_BOT(0); | 1490 partial_tv = *STACK_TV_BOT(0); |
1484 tv = &partial; | 1491 tv = &partial_tv; |
1485 } | 1492 } |
1486 r = call_partial(tv, pfunc->cpf_argcount, &ectx); | 1493 r = call_partial(tv, pfunc->cpf_argcount, &ectx); |
1487 if (tv == &partial) | 1494 if (tv == &partial_tv) |
1488 clear_tv(&partial); | 1495 clear_tv(&partial_tv); |
1489 if (r == FAIL) | 1496 if (r == FAIL) |
1490 goto failed; | 1497 goto failed; |
1491 } | 1498 } |
1492 break; | 1499 break; |
1493 | 1500 |