Mercurial > vim
comparison src/vim9execute.c @ 23156:6aa8ddf7a3fa v8.2.2124
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Commit: https://github.com/vim/vim/commit/08597875b2a1e7d118b0346c652a96e7527e7d8b
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 10 19:43:40 2020 +0100
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Problem: Vim9: a range cannot be computed at runtime.
Solution: Add the ISN_RANGE instruction.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 10 Dec 2020 19:45:04 +0100 |
parents | 3239b0f3c592 |
children | cc24ac009f29 |
comparison
equal
deleted
inserted
replaced
23155:1172003ef1bf | 23156:6aa8ddf7a3fa |
---|---|
2859 tv->vval.v_string = str; | 2859 tv->vval.v_string = str; |
2860 } | 2860 } |
2861 } | 2861 } |
2862 break; | 2862 break; |
2863 | 2863 |
2864 case ISN_RANGE: | |
2865 { | |
2866 exarg_T ea; | |
2867 char *errormsg; | |
2868 | |
2869 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) | |
2870 goto failed; | |
2871 ++ectx.ec_stack.ga_len; | |
2872 tv = STACK_TV_BOT(-1); | |
2873 ea.addr_type = ADDR_LINES; | |
2874 ea.cmd = iptr->isn_arg.string; | |
2875 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) | |
2876 goto failed; | |
2877 if (ea.addr_count == 0) | |
2878 tv->vval.v_number = curwin->w_cursor.lnum; | |
2879 else | |
2880 tv->vval.v_number = ea.line2; | |
2881 } | |
2882 break; | |
2883 | |
2864 case ISN_PUT: | 2884 case ISN_PUT: |
2865 { | 2885 { |
2866 int regname = iptr->isn_arg.put.put_regname; | 2886 int regname = iptr->isn_arg.put.put_regname; |
2867 linenr_T lnum = iptr->isn_arg.put.put_lnum; | 2887 linenr_T lnum = iptr->isn_arg.put.put_lnum; |
2868 char_u *expr = NULL; | 2888 char_u *expr = NULL; |
2878 expr = typval_tostring(tv); // allocates value | 2898 expr = typval_tostring(tv); // allocates value |
2879 clear_tv(tv); | 2899 clear_tv(tv); |
2880 } | 2900 } |
2881 --ectx.ec_stack.ga_len; | 2901 --ectx.ec_stack.ga_len; |
2882 } | 2902 } |
2883 if (lnum == -2) | 2903 if (lnum < -2) |
2904 { | |
2905 // line number was put on the stack by ISN_RANGE | |
2906 tv = STACK_TV_BOT(-1); | |
2907 curwin->w_cursor.lnum = tv->vval.v_number; | |
2908 if (lnum == LNUM_VARIABLE_RANGE_ABOVE) | |
2909 dir = BACKWARD; | |
2910 --ectx.ec_stack.ga_len; | |
2911 } | |
2912 else if (lnum == -2) | |
2884 // :put! above cursor | 2913 // :put! above cursor |
2885 dir = BACKWARD; | 2914 dir = BACKWARD; |
2886 else if (lnum >= 0) | 2915 else if (lnum >= 0) |
2887 curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum; | 2916 curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum; |
2888 check_cursor(); | 2917 check_cursor(); |
3688 (long long)(iptr->isn_arg.number)); | 3717 (long long)(iptr->isn_arg.number)); |
3689 break; | 3718 break; |
3690 case ISN_2STRING_ANY: smsg("%4d 2STRING_ANY stack[%lld]", current, | 3719 case ISN_2STRING_ANY: smsg("%4d 2STRING_ANY stack[%lld]", current, |
3691 (long long)(iptr->isn_arg.number)); | 3720 (long long)(iptr->isn_arg.number)); |
3692 break; | 3721 break; |
3722 case ISN_RANGE: smsg("%4d RANGE %s", current, iptr->isn_arg.string); | |
3723 break; | |
3693 case ISN_PUT: | 3724 case ISN_PUT: |
3694 smsg("%4d PUT %c %ld", current, iptr->isn_arg.put.put_regname, | 3725 if (iptr->isn_arg.put.put_lnum == LNUM_VARIABLE_RANGE_ABOVE) |
3726 smsg("%4d PUT %c above range", | |
3727 current, iptr->isn_arg.put.put_regname); | |
3728 else if (iptr->isn_arg.put.put_lnum == LNUM_VARIABLE_RANGE) | |
3729 smsg("%4d PUT %c range", | |
3730 current, iptr->isn_arg.put.put_regname); | |
3731 else | |
3732 smsg("%4d PUT %c %ld", current, | |
3733 iptr->isn_arg.put.put_regname, | |
3695 (long)iptr->isn_arg.put.put_lnum); | 3734 (long)iptr->isn_arg.put.put_lnum); |
3696 break; | 3735 break; |
3697 | 3736 |
3698 // TODO: summarize modifiers | 3737 // TODO: summarize modifiers |
3699 case ISN_CMDMOD: | 3738 case ISN_CMDMOD: |