Mercurial > vim
annotate src/vim9execute.c @ 30693:a59a8ce13129 v9.0.0681
patch 9.0.0681: "<<<" shows for 'smoothscroll' even when 'showbreak is set
Commit: https://github.com/vim/vim/commit/0937b9fb244949b7ce9bfcf8398d7495b9b6aa85
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 6 21:24:34 2022 +0100
patch 9.0.0681: "<<<" shows for 'smoothscroll' even when 'showbreak is set
Problem: "<<<" shows for 'smoothscroll' even when 'showbreak is set.
Solution: When 'showbreak' is set do not display "<<<".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Oct 2022 22:30:03 +0200 |
parents | 586b5b3aacf9 |
children | d914a3812d5b |
rev | line source |
---|---|
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * vim9execute.c: execute Vim9 script instructions |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #define USING_FLOAT_STUFF |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 #include "vim.h" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 #if defined(FEAT_EVAL) || defined(PROTO) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
26644
diff
changeset
|
19 // When not generating protos this is included in proto.h |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
26644
diff
changeset
|
20 #ifdef PROTO |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
26644
diff
changeset
|
21 # include "vim9.h" |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 // Structure put on ec_trystack when ISN_TRY is encountered. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 typedef struct { |
23921
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23917
diff
changeset
|
27 int tcd_frame_idx; // ec_frame_idx at ISN_TRY |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23917
diff
changeset
|
28 int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
29 int tcd_in_catch; // in catch or finally block |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
30 int tcd_did_throw; // set did_throw in :endtry |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
31 int tcd_catch_idx; // instruction of the first :catch or :finally |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
32 int tcd_finally_idx; // instruction of the :finally block or zero |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
33 int tcd_endtry_idx; // instruction of the :endtry |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 int tcd_caught; // catch block entered |
24122
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24112
diff
changeset
|
35 int tcd_cont; // :continue encountered, jump here (minus one) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 int tcd_return; // when TRUE return from end of :finally |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 } trycmd_T; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
39 // Data local to a function. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
40 // On a function call, if not empty, is saved on the stack and restored when |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
41 // returning. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
42 typedef struct { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
43 int floc_restore_cmdmod; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
44 cmdmod_T floc_save_cmdmod; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
45 int floc_restore_cmdmod_stacklen; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
46 } funclocal_T; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
48 // Structure to hold a reference to an outer_T, with information of whether it |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
49 // was allocated. |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
50 typedef struct { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
51 outer_T *or_outer; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
52 partial_T *or_partial; // decrement "or_partial->pt_refcount" later |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
53 int or_outer_allocated; // free "or_outer" later |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
54 } outer_ref_T; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
55 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 // A stack is used to store: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 // - arguments passed to a :def function |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 // - info about the calling function, to use when returning |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 // - local variables |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 // - temporary values |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 // |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 // In detail (FP == Frame Pointer): |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 // arg1 first argument from caller (if present) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 // arg2 second argument from caller (if present) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 // extra_arg1 any missing optional argument default value |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 // FP -> cur_func calling function |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
67 // current previous instruction pointer |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
68 // frame_ptr previous Frame Pointer |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
69 // var1 space for local variable |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
70 // var2 space for local variable |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
71 // .... fixed space for max. number of local variables |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
72 // temp temporary values |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
73 // .... flexible space for temporary values (can grow big) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 * Execution context. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 */ |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
78 struct ectx_S { |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 garray_T ec_stack; // stack of typval_T values |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
80 int ec_frame_idx; // index in ec_stack: context of ec_dfunc_idx |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
81 int ec_initial_frame_idx; // frame index when called |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
83 outer_ref_T *ec_outer_ref; // outer scope used for closures, allocated |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
84 funclocal_T ec_funclocal; |
20244
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20225
diff
changeset
|
85 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 garray_T ec_trystack; // stack of trycmd_T values |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 |
25533
df39041f13ed
patch 8.2.3303: some structures could be smaller
Bram Moolenaar <Bram@vim.org>
parents:
25477
diff
changeset
|
88 isn_T *ec_instr; // array with instructions |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 int ec_dfunc_idx; // current function index |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 int ec_iidx; // index in ec_instr: instruction to execute |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
91 |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
92 garray_T ec_funcrefs; // partials that might be a closure |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
93 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
94 int ec_did_emsg_before; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
95 int ec_trylevel_at_start; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
96 where_T ec_where; |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
97 }; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
99 #ifdef FEAT_PROFILE |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
100 // stack of profinfo_T used when profiling. |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
101 static garray_T profile_info_ga = {0, 0, sizeof(profinfo_T), 20, NULL}; |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
102 #endif |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
103 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
104 // Get pointer to item in the stack. |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
105 #define STACK_TV(idx) (((typval_T *)ectx->ec_stack.ga_data) + idx) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
106 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 // Get pointer to item relative to the bottom of the stack, -1 is the last one. |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
108 #define STACK_TV_BOT(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_stack.ga_len + (idx)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
110 // Get pointer to a local variable on the stack. Negative for arguments. |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
111 #define STACK_TV_VAR(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_frame_idx + STACK_FRAME_SIZE + idx) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
112 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
113 void |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
114 to_string_error(vartype_T vartype) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
115 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
116 semsg(_(e_cannot_convert_str_to_string), vartype_name(vartype)); |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
117 } |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
118 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 /* |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
120 * Return the number of arguments, including optional arguments and any vararg. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 static int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 ufunc_argcount(ufunc_T *ufunc) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 return ufunc->uf_args.ga_len + (ufunc->uf_va_name != NULL ? 1 : 0); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 /* |
28598
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
129 * Create a new string from "count" items at the bottom of the stack. |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
130 * A trailing NUL is appended. |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
131 * When "count" is zero an empty string is added to the stack. |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
132 */ |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
133 static int |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
134 exe_concat(int count, ectx_T *ectx) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
135 { |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
136 int idx; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
137 int len = 0; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
138 typval_T *tv; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
139 garray_T ga; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
140 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
141 ga_init2(&ga, sizeof(char), 1); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
142 // Preallocate enough space for the whole string to avoid having to grow |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
143 // and copy. |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
144 for (idx = 0; idx < count; ++idx) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
145 { |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
146 tv = STACK_TV_BOT(idx - count); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
147 if (tv->vval.v_string != NULL) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
148 len += (int)STRLEN(tv->vval.v_string); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
149 } |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
150 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
151 if (ga_grow(&ga, len + 1) == FAIL) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
152 return FAIL; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
153 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
154 for (idx = 0; idx < count; ++idx) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
155 { |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
156 tv = STACK_TV_BOT(idx - count); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
157 ga_concat(&ga, tv->vval.v_string); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
158 clear_tv(tv); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
159 } |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
160 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
161 // add a terminating NUL |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
162 ga_append(&ga, NUL); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
163 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
164 ectx->ec_stack.ga_len -= count - 1; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
165 STACK_TV_BOT(-1)->vval.v_string = ga.ga_data; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
166 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
167 return OK; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
168 } |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
169 |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
170 /* |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
171 * Create a new list from "count" items at the bottom of the stack. |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
172 * When "count" is zero an empty list is added to the stack. |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
173 * When "count" is -1 a NULL list is added to the stack. |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
174 */ |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
175 static int |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
176 exe_newlist(int count, ectx_T *ectx) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
177 { |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
178 list_T *list = NULL; |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
179 int idx; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
180 typval_T *tv; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
181 |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
182 if (count >= 0) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
183 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
184 list = list_alloc_with_items(count); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
185 if (list == NULL) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
186 return FAIL; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
187 for (idx = 0; idx < count; ++idx) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
188 list_set_item(list, idx, STACK_TV_BOT(idx - count)); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
189 } |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
190 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
191 if (count > 0) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
192 ectx->ec_stack.ga_len -= count - 1; |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
193 else if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
194 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
195 list_unref(list); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
196 return FAIL; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
197 } |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
198 else |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
199 ++ectx->ec_stack.ga_len; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
200 tv = STACK_TV_BOT(-1); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
201 tv->v_type = VAR_LIST; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
202 tv->vval.v_list = list; |
30327
7fde373affbf
patch 9.0.0499: in :def function list created after const is locked
Bram Moolenaar <Bram@vim.org>
parents:
30318
diff
changeset
|
203 tv->v_lock = 0; |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
204 if (list != NULL) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
205 ++list->lv_refcount; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
206 return OK; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
207 } |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
208 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
209 /* |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
210 * Implementation of ISN_NEWDICT. |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
211 * Returns FAIL on total failure, MAYBE on error. |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
212 */ |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
213 static int |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
214 exe_newdict(int count, ectx_T *ectx) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
215 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
216 dict_T *dict = NULL; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
217 dictitem_T *item; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
218 char_u *key; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
219 int idx; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
220 typval_T *tv; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
221 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
222 if (count >= 0) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
223 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
224 dict = dict_alloc(); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
225 if (unlikely(dict == NULL)) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
226 return FAIL; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
227 for (idx = 0; idx < count; ++idx) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
228 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
229 // have already checked key type is VAR_STRING |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
230 tv = STACK_TV_BOT(2 * (idx - count)); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
231 // check key is unique |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
232 key = tv->vval.v_string == NULL |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
233 ? (char_u *)"" : tv->vval.v_string; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
234 item = dict_find(dict, key, -1); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
235 if (item != NULL) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
236 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
237 semsg(_(e_duplicate_key_in_dicitonary), key); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
238 dict_unref(dict); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
239 return MAYBE; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
240 } |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
241 item = dictitem_alloc(key); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
242 clear_tv(tv); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
243 if (unlikely(item == NULL)) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
244 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
245 dict_unref(dict); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
246 return FAIL; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
247 } |
28343
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28309
diff
changeset
|
248 tv = STACK_TV_BOT(2 * (idx - count) + 1); |
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28309
diff
changeset
|
249 item->di_tv = *tv; |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
250 item->di_tv.v_lock = 0; |
28343
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28309
diff
changeset
|
251 tv->v_type = VAR_UNKNOWN; |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
252 if (dict_add(dict, item) == FAIL) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
253 { |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
254 // can this ever happen? |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
255 dict_unref(dict); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
256 return FAIL; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
257 } |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
258 } |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
259 } |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
260 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
261 if (count > 0) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
262 ectx->ec_stack.ga_len -= 2 * count - 1; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
263 else if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
264 return FAIL; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
265 else |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
266 ++ectx->ec_stack.ga_len; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
267 tv = STACK_TV_BOT(-1); |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
268 tv->v_type = VAR_DICT; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
269 tv->v_lock = 0; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
270 tv->vval.v_dict = dict; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
271 if (dict != NULL) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
272 ++dict->dv_refcount; |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
273 return OK; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
274 } |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
275 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
276 /* |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
277 * If debug_tick changed check if "ufunc" has a breakpoint and update |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
278 * "uf_has_breakpoint". |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
279 */ |
28097
632a84e2ce92
patch 8.2.4573: a nested function is compiled for debugging without context
Bram Moolenaar <Bram@vim.org>
parents:
28033
diff
changeset
|
280 void |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
281 update_has_breakpoint(ufunc_T *ufunc) |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
282 { |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
283 if (ufunc->uf_debug_tick != debug_tick) |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
284 { |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
285 linenr_T breakpoint; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
286 |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
287 ufunc->uf_debug_tick = debug_tick; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
288 breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, 0); |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
289 ufunc->uf_has_breakpoint = breakpoint > 0; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
290 } |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
291 } |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
292 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
293 static garray_T dict_stack = GA_EMPTY; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
294 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
295 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
296 * Put a value on the dict stack. This consumes "tv". |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
297 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
298 static int |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
299 dict_stack_save(typval_T *tv) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
300 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
301 if (dict_stack.ga_growsize == 0) |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
27026
diff
changeset
|
302 ga_init2(&dict_stack, sizeof(typval_T), 10); |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
303 if (ga_grow(&dict_stack, 1) == FAIL) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
304 return FAIL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
305 ((typval_T *)dict_stack.ga_data)[dict_stack.ga_len] = *tv; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
306 ++dict_stack.ga_len; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
307 return OK; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
308 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
309 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
310 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
311 * Get the typval at top of the dict stack. |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
312 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
313 static typval_T * |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
314 dict_stack_get_tv(void) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
315 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
316 if (dict_stack.ga_len == 0) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
317 return NULL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
318 return ((typval_T *)dict_stack.ga_data) + dict_stack.ga_len - 1; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
319 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
320 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
321 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
322 * Get the dict at top of the dict stack. |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
323 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
324 static dict_T * |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
325 dict_stack_get_dict(void) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
326 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
327 typval_T *tv; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
328 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
329 if (dict_stack.ga_len == 0) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
330 return NULL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
331 tv = ((typval_T *)dict_stack.ga_data) + dict_stack.ga_len - 1; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
332 if (tv->v_type == VAR_DICT) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
333 return tv->vval.v_dict; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
334 return NULL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
335 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
336 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
337 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
338 * Drop an item from the dict stack. |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
339 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
340 static void |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
341 dict_stack_drop(void) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
342 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
343 if (dict_stack.ga_len == 0) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
344 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
345 iemsg("Dict stack underflow"); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
346 return; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
347 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
348 --dict_stack.ga_len; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
349 clear_tv(((typval_T *)dict_stack.ga_data) + dict_stack.ga_len); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
350 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
351 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
352 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
353 * Drop items from the dict stack until the length is equal to "len". |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
354 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
355 static void |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
356 dict_stack_clear(int len) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
357 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
358 while (dict_stack.ga_len > len) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
359 dict_stack_drop(); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
360 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
361 |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
362 /* |
27591
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
363 * Get a pointer to useful "pt_outer" of "pt". |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
364 */ |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
365 static outer_T * |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
366 get_pt_outer(partial_T *pt) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
367 { |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
368 partial_T *ptref = pt->pt_outer_partial; |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
369 |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
370 if (ptref == NULL) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
371 return &pt->pt_outer; |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
372 |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
373 // partial using partial (recursively) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
374 while (ptref->pt_outer_partial != NULL) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
375 ptref = ptref->pt_outer_partial; |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
376 return &ptref->pt_outer; |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
377 } |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
378 |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
379 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 * Call compiled function "cdf_idx" from compiled code. |
23557
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
381 * This adds a stack frame and sets the instruction pointer to the start of the |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
382 * called function. |
30427
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
383 * If "pt_arg" is not NULL use "pt_arg->pt_outer" for ec_outer_ref->or_outer. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 * Stack has: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 * - current arguments (already there) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 * - omitted optional argument (default values) added here |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 * - stack frame: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 * - pointer to calling function |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 * - Index of next instruction in calling function |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 * - previous frame pointer |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 * - reserved space for local variables |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 static int |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
395 call_dfunc( |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
396 int cdf_idx, |
30427
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
397 partial_T *pt_arg, |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
398 int argcount_arg, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
399 ectx_T *ectx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 { |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
401 int argcount = argcount_arg; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
402 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + cdf_idx; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
403 ufunc_T *ufunc = dfunc->df_ufunc; |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
404 int did_emsg_before = did_emsg_cumul + did_emsg; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
405 int arg_to_add; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
406 int vararg_count = 0; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
407 int varcount; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
408 int idx; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
409 estack_T *entry; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
410 funclocal_T *floc = NULL; |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
411 int res = OK; |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
412 compiletype_T compile_type; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 if (dfunc->df_deleted) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 { |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
416 // don't use ufunc->uf_name, it may have been freed |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
417 emsg_funcname(e_function_was_deleted_str, |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
418 dfunc->df_name == NULL ? (char_u *)"unknown" : dfunc->df_name); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 |
23735
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
422 #ifdef FEAT_PROFILE |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
423 if (do_profiling == PROF_YES) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
424 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
425 if (GA_GROW_OK(&profile_info_ga, 1)) |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
426 { |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
427 profinfo_T *info = ((profinfo_T *)profile_info_ga.ga_data) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
428 + profile_info_ga.ga_len; |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
429 ++profile_info_ga.ga_len; |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
430 CLEAR_POINTER(info); |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
431 profile_may_start_func(info, ufunc, |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
432 (((dfunc_T *)def_functions.ga_data) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
433 + ectx->ec_dfunc_idx)->df_ufunc); |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
434 } |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
435 } |
23735
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
436 #endif |
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
437 |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
438 // When debugging and using "cont" switches to the not-debugged |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
439 // instructions, may need to still compile them. |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
440 compile_type = get_compile_type(ufunc); |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
441 if (func_needs_compiling(ufunc, compile_type)) |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
442 { |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
443 res = compile_def_function(ufunc, FALSE, compile_type, NULL); |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
444 |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
445 // compile_def_function() may cause def_functions.ga_data to change |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
446 dfunc = ((dfunc_T *)def_functions.ga_data) + cdf_idx; |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
447 } |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
448 if (res == FAIL || INSTRUCTIONS(dfunc) == NULL) |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
449 { |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
450 if (did_emsg_cumul + did_emsg == did_emsg_before) |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
451 semsg(_(e_function_is_not_compiled_str), |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
452 printable_func_name(ufunc)); |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
453 return FAIL; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
454 } |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
455 |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
456 if (ufunc->uf_va_name != NULL) |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
457 { |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
458 // Need to make a list out of the vararg arguments. |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
459 // Stack at time of call with 2 varargs: |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
460 // normal_arg |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
461 // optional_arg |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
462 // vararg_1 |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
463 // vararg_2 |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
464 // After creating the list: |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
465 // normal_arg |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
466 // optional_arg |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
467 // vararg-list |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
468 // With missing optional arguments we get: |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
469 // normal_arg |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
470 // After creating the list |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
471 // normal_arg |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
472 // (space for optional_arg) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
473 // vararg-list |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
474 vararg_count = argcount - ufunc->uf_args.ga_len; |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
475 if (vararg_count < 0) |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
476 vararg_count = 0; |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
477 else |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
478 argcount -= vararg_count; |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
479 if (exe_newlist(vararg_count, ectx) == FAIL) |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
480 return FAIL; |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
481 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
482 vararg_count = 1; |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
483 } |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
484 |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
485 arg_to_add = ufunc->uf_args.ga_len - argcount; |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
486 if (arg_to_add < 0) |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
487 { |
29322
ac102d0fb50f
patch 9.0.0004: plural messages not translated properly
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
488 semsg(NGETTEXT(e_one_argument_too_many, e_nr_arguments_too_many, |
ac102d0fb50f
patch 9.0.0004: plural messages not translated properly
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
489 -arg_to_add), -arg_to_add); |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
490 return FAIL; |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
491 } |
27756
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27665
diff
changeset
|
492 else if (arg_to_add > ufunc->uf_def_args.ga_len) |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27665
diff
changeset
|
493 { |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27665
diff
changeset
|
494 int missing = arg_to_add - ufunc->uf_def_args.ga_len; |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27665
diff
changeset
|
495 |
29322
ac102d0fb50f
patch 9.0.0004: plural messages not translated properly
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
496 semsg(NGETTEXT(e_one_argument_too_few, e_nr_arguments_too_few, |
ac102d0fb50f
patch 9.0.0004: plural messages not translated properly
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
497 missing), missing); |
27756
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27665
diff
changeset
|
498 return FAIL; |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27665
diff
changeset
|
499 } |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
500 |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
501 // Reserve space for: |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
502 // - missing arguments |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
503 // - stack frame |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
504 // - local variables |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
505 // - if needed: a counter for number of closures created in |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
506 // ectx->ec_funcrefs. |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
507 varcount = dfunc->df_varcount + dfunc->df_has_closure; |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
508 if (GA_GROW_FAILS(&ectx->ec_stack, |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
509 arg_to_add + STACK_FRAME_SIZE + varcount)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
512 // If depth of calling is getting too high, don't execute the function. |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
513 if (funcdepth_increment() == FAIL) |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
514 return FAIL; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
515 ++ex_nesting_level; |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
516 |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
517 // Only make a copy of funclocal if it contains something to restore. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
518 if (ectx->ec_funclocal.floc_restore_cmdmod) |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
519 { |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
520 floc = ALLOC_ONE(funclocal_T); |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
521 if (floc == NULL) |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
522 return FAIL; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
523 *floc = ectx->ec_funclocal; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
524 ectx->ec_funclocal.floc_restore_cmdmod = FALSE; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
525 } |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
526 |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
527 // Move the vararg-list to below the missing optional arguments. |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
528 if (vararg_count > 0 && arg_to_add > 0) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
529 *STACK_TV_BOT(arg_to_add - 1) = *STACK_TV_BOT(-1); |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
530 |
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
531 // Reserve space for omitted optional arguments, filled in soon. |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
532 for (idx = 0; idx < arg_to_add; ++idx) |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
533 STACK_TV_BOT(idx - vararg_count)->v_type = VAR_UNKNOWN; |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
534 ectx->ec_stack.ga_len += arg_to_add; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 // Store current execution state in stack frame for ISN_RETURN. |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
537 STACK_TV_BOT(STACK_FRAME_FUNC_OFF)->vval.v_number = ectx->ec_dfunc_idx; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
538 STACK_TV_BOT(STACK_FRAME_IIDX_OFF)->vval.v_number = ectx->ec_iidx; |
24545
fe29b220eece
patch 8.2.2812: Vim9: still crash when using substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
24541
diff
changeset
|
539 STACK_TV_BOT(STACK_FRAME_INSTR_OFF)->vval.v_string = (void *)ectx->ec_instr; |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
540 STACK_TV_BOT(STACK_FRAME_OUTER_OFF)->vval.v_string = |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
541 (void *)ectx->ec_outer_ref; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
542 STACK_TV_BOT(STACK_FRAME_FUNCLOCAL_OFF)->vval.v_string = (void *)floc; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
543 STACK_TV_BOT(STACK_FRAME_IDX_OFF)->vval.v_number = ectx->ec_frame_idx; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
544 ectx->ec_frame_idx = ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 |
30427
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
546 // Initialize all local variables to number zero. Also initialize the |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
547 // variable that counts how many closures were created. This is used in |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
548 // handle_closure_in_use(). |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
549 int initcount = dfunc->df_varcount + (dfunc->df_has_closure ? 1 : 0); |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
550 for (idx = 0; idx < initcount; ++idx) |
26729
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
551 { |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
552 typval_T *tv = STACK_TV_BOT(STACK_FRAME_SIZE + idx); |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
553 |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
554 tv->v_type = VAR_NUMBER; |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
555 tv->vval.v_number = 0; |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
556 } |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
557 ectx->ec_stack.ga_len += STACK_FRAME_SIZE + varcount; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 |
30427
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
559 partial_T *pt = pt_arg != NULL ? pt_arg : ufunc->uf_partial; |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
560 if (pt != NULL || (ufunc->uf_flags & FC_CLOSURE)) |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
561 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
562 outer_ref_T *ref = ALLOC_CLEAR_ONE(outer_ref_T); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
563 |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
564 if (ref == NULL) |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
565 return FAIL; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
566 if (pt != NULL) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
567 { |
27591
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
568 ref->or_outer = get_pt_outer(pt); |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
569 ++pt->pt_refcount; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
570 ref->or_partial = pt; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
571 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
572 else |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
573 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
574 ref->or_outer = ALLOC_CLEAR_ONE(outer_T); |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
575 if (unlikely(ref->or_outer == NULL)) |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
576 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
577 vim_free(ref); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
578 return FAIL; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
579 } |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
580 ref->or_outer_allocated = TRUE; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
581 ref->or_outer->out_stack = &ectx->ec_stack; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
582 ref->or_outer->out_frame_idx = ectx->ec_frame_idx; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
583 if (ectx->ec_outer_ref != NULL) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
584 ref->or_outer->out_up = ectx->ec_outer_ref->or_outer; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
585 } |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
586 ectx->ec_outer_ref = ref; |
23557
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
587 } |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
588 else |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
589 ectx->ec_outer_ref = NULL; |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
590 |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
591 ++ufunc->uf_calls; |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
592 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 // Set execution state to the start of the called function. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 ectx->ec_dfunc_idx = cdf_idx; |
23735
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
595 ectx->ec_instr = INSTRUCTIONS(dfunc); |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
596 entry = estack_push_ufunc(ufunc, 1); |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
597 if (entry != NULL) |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
598 { |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
599 // Set the script context to the script where the function was defined. |
24471
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24454
diff
changeset
|
600 // Save the current context so it can be restored on return. |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24454
diff
changeset
|
601 entry->es_save_sctx = current_sctx; |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24454
diff
changeset
|
602 current_sctx = ufunc->uf_script_ctx; |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
603 } |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
604 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
605 // Start execution at the first instruction. |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
606 ectx->ec_iidx = 0; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
611 // Double linked list of funcstack_T in use. |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
612 static funcstack_T *first_funcstack = NULL; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
613 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
614 static void |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
615 add_funcstack_to_list(funcstack_T *funcstack) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
616 { |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
617 // Link in list of funcstacks. |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
618 if (first_funcstack != NULL) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
619 first_funcstack->fs_prev = funcstack; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
620 funcstack->fs_next = first_funcstack; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
621 funcstack->fs_prev = NULL; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
622 first_funcstack = funcstack; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
623 } |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
624 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
625 static void |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
626 remove_funcstack_from_list(funcstack_T *funcstack) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
627 { |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
628 if (funcstack->fs_prev == NULL) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
629 first_funcstack = funcstack->fs_next; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
630 else |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
631 funcstack->fs_prev->fs_next = funcstack->fs_next; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
632 if (funcstack->fs_next != NULL) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
633 funcstack->fs_next->fs_prev = funcstack->fs_prev; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
634 } |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
635 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 /* |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
637 * Used when returning from a function: Check if any closure is still |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
638 * referenced. If so then move the arguments and variables to a separate piece |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
639 * of stack to be used when the closure is called. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
640 * When "free_arguments" is TRUE the arguments are to be freed. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
641 * Returns FAIL when out of memory. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
642 */ |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
643 static int |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
644 handle_closure_in_use(ectx_T *ectx, int free_arguments) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
645 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
646 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
647 + ectx->ec_dfunc_idx; |
22324
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
648 int argcount; |
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
649 int top; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
650 int idx; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
651 typval_T *tv; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
652 int closure_in_use = FALSE; |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
653 garray_T *gap = &ectx->ec_funcrefs; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
654 varnumber_T closure_count; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
655 |
22324
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
656 if (dfunc->df_ufunc == NULL) |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
657 return OK; // function was freed |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
658 if (dfunc->df_has_closure == 0) |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
659 return OK; // no closures |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
660 tv = STACK_TV(ectx->ec_frame_idx + STACK_FRAME_SIZE + dfunc->df_varcount); |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
661 closure_count = tv->vval.v_number; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
662 if (closure_count == 0) |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
663 return OK; // no funcrefs created |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
664 |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
665 // Compute "top": the first entry in the stack used by the function. |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
666 // This is the first argument (after that comes the stack frame and then |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
667 // the local variables). |
22324
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
668 argcount = ufunc_argcount(dfunc->df_ufunc); |
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
669 top = ectx->ec_frame_idx - argcount; |
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
670 |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
671 // Check if any created closure is still in use. |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
672 for (idx = 0; idx < closure_count; ++idx) |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
673 { |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
674 partial_T *pt; |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
675 int off = gap->ga_len - closure_count + idx; |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
676 |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
677 if (off < 0) |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
678 continue; // count is off or already done |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
679 pt = ((partial_T **)gap->ga_data)[off]; |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
680 if (pt->pt_refcount > 1) |
20257
683c2da4982b
patch 8.2.0684: Vim9: memory leak when using lambda
Bram Moolenaar <Bram@vim.org>
parents:
20255
diff
changeset
|
681 { |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
682 int refcount = pt->pt_refcount; |
20283
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
683 int i; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
684 |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
685 // A Reference in a local variable doesn't count, it gets |
20283
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
686 // unreferenced on return. |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
687 for (i = 0; i < dfunc->df_varcount; ++i) |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
688 { |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
689 typval_T *stv = STACK_TV(ectx->ec_frame_idx |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
690 + STACK_FRAME_SIZE + i); |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
691 if (stv->v_type == VAR_PARTIAL && pt == stv->vval.v_partial) |
20283
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
692 --refcount; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
693 } |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
694 if (refcount > 1) |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
695 { |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
696 closure_in_use = TRUE; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
697 break; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
698 } |
20257
683c2da4982b
patch 8.2.0684: Vim9: memory leak when using lambda
Bram Moolenaar <Bram@vim.org>
parents:
20255
diff
changeset
|
699 } |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
700 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
701 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
702 if (closure_in_use) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
703 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
704 funcstack_T *funcstack = ALLOC_CLEAR_ONE(funcstack_T); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
705 typval_T *stack; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
706 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
707 // A closure is using the arguments and/or local variables. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
708 // Move them to the called function. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
709 if (funcstack == NULL) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
710 return FAIL; |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
711 |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
712 funcstack->fs_var_offset = argcount + STACK_FRAME_SIZE; |
30564
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
713 funcstack->fs_ga.ga_len = funcstack->fs_var_offset |
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
714 + dfunc->df_varcount; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
715 stack = ALLOC_CLEAR_MULT(typval_T, funcstack->fs_ga.ga_len); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
716 funcstack->fs_ga.ga_data = stack; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
717 if (stack == NULL) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
718 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
719 vim_free(funcstack); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
720 return FAIL; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
721 } |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
722 add_funcstack_to_list(funcstack); |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
723 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
724 // Move or copy the arguments. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
725 for (idx = 0; idx < argcount; ++idx) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
726 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
727 tv = STACK_TV(top + idx); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
728 if (free_arguments) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
729 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
730 *(stack + idx) = *tv; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
731 tv->v_type = VAR_UNKNOWN; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
732 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
733 else |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
734 copy_tv(tv, stack + idx); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
735 } |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
736 // Skip the stack frame. |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
737 // Move the local variables. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
738 for (idx = 0; idx < dfunc->df_varcount; ++idx) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
739 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
740 tv = STACK_TV(ectx->ec_frame_idx + STACK_FRAME_SIZE + idx); |
20297
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
741 |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
742 // A partial created for a local function, that is also used as a |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
743 // local variable, has a reference count for the variable, thus |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
744 // will never go down to zero. When all these refcounts are one |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
745 // then the funcstack is unused. We need to count how many we have |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
746 // so we know when to check. |
20297
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
747 if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial != NULL) |
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
748 { |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
749 int i; |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
750 |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
751 for (i = 0; i < closure_count; ++i) |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
752 if (tv->vval.v_partial == ((partial_T **)gap->ga_data)[ |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
753 gap->ga_len - closure_count + i]) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
754 ++funcstack->fs_min_refcount; |
20297
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
755 } |
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
756 |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
757 *(stack + funcstack->fs_var_offset + idx) = *tv; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
758 tv->v_type = VAR_UNKNOWN; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
759 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
760 |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
761 for (idx = 0; idx < closure_count; ++idx) |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
762 { |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
763 partial_T *pt = ((partial_T **)gap->ga_data)[gap->ga_len |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
764 - closure_count + idx]; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
765 if (pt->pt_refcount > 1) |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
766 { |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
767 ++funcstack->fs_refcount; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
768 pt->pt_funcstack = funcstack; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
769 pt->pt_outer.out_stack = &funcstack->fs_ga; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
770 pt->pt_outer.out_frame_idx = ectx->ec_frame_idx - top; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
771 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
772 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
773 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
774 |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
775 for (idx = 0; idx < closure_count; ++idx) |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
776 partial_unref(((partial_T **)gap->ga_data)[gap->ga_len |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
777 - closure_count + idx]); |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
778 gap->ga_len -= closure_count; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
779 if (gap->ga_len == 0) |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
780 ga_clear(gap); |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
781 |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
782 return OK; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
783 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
784 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
785 /* |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
786 * Called when a partial is freed or its reference count goes down to one. The |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
787 * funcstack may be the only reference to the partials in the local variables. |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
788 * Go over all of them, the funcref and can be freed if all partials |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
789 * referencing the funcstack have a reference count of one. |
30302
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
790 * Returns TRUE if the funcstack is freed, the partial referencing it will then |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
791 * also have been freed. |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
792 */ |
30302
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
793 int |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
794 funcstack_check_refcount(funcstack_T *funcstack) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
795 { |
30302
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
796 int i; |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
797 garray_T *gap = &funcstack->fs_ga; |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
798 int done = 0; |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
799 typval_T *stack; |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
800 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
801 if (funcstack->fs_refcount > funcstack->fs_min_refcount) |
30302
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
802 return FALSE; |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
803 for (i = funcstack->fs_var_offset; i < gap->ga_len; ++i) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
804 { |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
805 typval_T *tv = ((typval_T *)gap->ga_data) + i; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
806 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
807 if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial != NULL |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
808 && tv->vval.v_partial->pt_funcstack == funcstack |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
809 && tv->vval.v_partial->pt_refcount == 1) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
810 ++done; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
811 } |
30302
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
812 if (done != funcstack->fs_min_refcount) |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
813 return FALSE; |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
814 |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
815 stack = gap->ga_data; |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
816 |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
817 // All partials referencing the funcstack have a reference count of |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
818 // one, thus the funcstack is no longer of use. |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
819 for (i = 0; i < gap->ga_len; ++i) |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
820 clear_tv(stack + i); |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
821 vim_free(stack); |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
822 remove_funcstack_from_list(funcstack); |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
823 vim_free(funcstack); |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
824 |
6a1ed021a0c0
patch 9.0.0487: using freed memory with combination of closures
Bram Moolenaar <Bram@vim.org>
parents:
30299
diff
changeset
|
825 return TRUE; |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
826 } |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
827 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
828 /* |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
829 * For garbage collecting: set references in all variables referenced by |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
830 * all funcstacks. |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
831 */ |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
832 int |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
833 set_ref_in_funcstacks(int copyID) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
834 { |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
835 funcstack_T *funcstack; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
836 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
837 for (funcstack = first_funcstack; funcstack != NULL; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
838 funcstack = funcstack->fs_next) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
839 { |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
840 typval_T *stack = funcstack->fs_ga.ga_data; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
841 int i; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
842 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
843 for (i = 0; i < funcstack->fs_ga.ga_len; ++i) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
844 if (set_ref_in_item(stack + i, copyID, NULL, NULL)) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
845 return TRUE; // abort |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
846 } |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
847 return FALSE; |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
848 } |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
849 |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
850 // Ugly static to avoid passing the execution context around through many |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
851 // layers. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
852 static ectx_T *current_ectx = NULL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
853 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
854 /* |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
855 * Return TRUE if currently executing a :def function. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
856 * Can be used by builtin functions only. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
857 */ |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
858 int |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
859 in_def_function(void) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
860 { |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
861 return current_ectx != NULL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
862 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
863 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
864 /* |
30126
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
865 * Clear "current_ectx" and return the previous value. To be used when calling |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
866 * a user function. |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
867 */ |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
868 ectx_T * |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
869 clear_currrent_ectx(void) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
870 { |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
871 ectx_T *r = current_ectx; |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
872 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
873 current_ectx = NULL; |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
874 return r; |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
875 } |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
876 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
877 void |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
878 restore_current_ectx(ectx_T *ectx) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
879 { |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
880 if (current_ectx != NULL) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
881 iemsg("Restoring current_ectx while it is not NULL"); |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
882 current_ectx = ectx; |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
883 } |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
884 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
885 /* |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
886 * Add an entry for a deferred function call to the currently executing |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
887 * function. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
888 * Return the list or NULL when failed. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
889 */ |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
890 static list_T * |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
891 add_defer_item(int var_idx, int argcount, ectx_T *ectx) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
892 { |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
893 typval_T *defer_tv = STACK_TV_VAR(var_idx); |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
894 list_T *defer_l; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
895 list_T *l; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
896 typval_T listval; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
897 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
898 if (defer_tv->v_type != VAR_LIST) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
899 { |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
900 // first time, allocate the list |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
901 if (rettv_list_alloc(defer_tv) == FAIL) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
902 return NULL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
903 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
904 defer_l = defer_tv->vval.v_list; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
905 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
906 l = list_alloc_with_items(argcount + 1); |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
907 if (l == NULL) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
908 return NULL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
909 listval.v_type = VAR_LIST; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
910 listval.vval.v_list = l; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
911 listval.v_lock = 0; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
912 if (list_insert_tv(defer_l, &listval, defer_l->lv_first) == FAIL) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
913 { |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
914 vim_free(l); |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
915 return NULL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
916 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
917 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
918 return l; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
919 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
920 |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26558
diff
changeset
|
921 /* |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
922 * Handle ISN_DEFER. Stack has a function reference and "argcount" arguments. |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
923 * The local variable that lists deferred functions is "var_idx". |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
924 * Returns OK or FAIL. |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
925 */ |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
926 static int |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
927 defer_command(int var_idx, int argcount, ectx_T *ectx) |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
928 { |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
929 list_T *l = add_defer_item(var_idx, argcount, ectx); |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
930 int i; |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
931 typval_T *func_tv; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
932 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
933 if (l == NULL) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
934 return FAIL; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
935 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
936 func_tv = STACK_TV_BOT(-argcount - 1); |
30209
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
937 if (func_tv->v_type != VAR_FUNC && func_tv->v_type != VAR_PARTIAL) |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
938 { |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
939 semsg(_(e_expected_str_but_got_str), |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
940 "function or partial", |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
941 vartype_name(func_tv->v_type)); |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
942 return FAIL; |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
943 } |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
944 list_set_item(l, 0, func_tv); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
945 |
30209
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
946 for (i = 0; i < argcount; ++i) |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
947 list_set_item(l, i + 1, STACK_TV_BOT(-argcount + i)); |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
948 ectx->ec_stack.ga_len -= argcount + 1; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
949 return OK; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
950 } |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
951 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
952 /* |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
953 * Add a deferred function "name" with one argument "arg_tv". |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
954 * Consumes "name", also on failure. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
955 * Only to be called when in_def_function() returns TRUE. |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
956 */ |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
957 int |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
958 add_defer_function(char_u *name, int argcount, typval_T *argvars) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
959 { |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
960 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
961 + current_ectx->ec_dfunc_idx; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
962 list_T *l; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
963 typval_T func_tv; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
964 int i; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
965 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
966 if (dfunc->df_defer_var_idx == 0) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
967 { |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
968 iemsg("df_defer_var_idx is zero"); |
30092
53e7e912eeec
patch 9.0.0382: freeing the wrong string on failure
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
969 vim_free(name); |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
970 return FAIL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
971 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
972 |
30209
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30192
diff
changeset
|
973 l = add_defer_item(dfunc->df_defer_var_idx - 1, argcount, current_ectx); |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
974 if (l == NULL) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
975 { |
30092
53e7e912eeec
patch 9.0.0382: freeing the wrong string on failure
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
976 vim_free(name); |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
977 return FAIL; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
978 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
979 |
30092
53e7e912eeec
patch 9.0.0382: freeing the wrong string on failure
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
980 func_tv.v_type = VAR_FUNC; |
53e7e912eeec
patch 9.0.0382: freeing the wrong string on failure
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
981 func_tv.v_lock = 0; |
53e7e912eeec
patch 9.0.0382: freeing the wrong string on failure
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
982 func_tv.vval.v_string = name; |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
983 list_set_item(l, 0, &func_tv); |
30092
53e7e912eeec
patch 9.0.0382: freeing the wrong string on failure
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
984 |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
985 for (i = 0; i < argcount; ++i) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
986 list_set_item(l, i + 1, argvars + i); |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
987 return OK; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
988 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
989 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
990 /* |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
991 * Invoked when returning from a function: Invoke any deferred calls. |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
992 */ |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
993 static void |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
994 invoke_defer_funcs(ectx_T *ectx) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
995 { |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
996 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
997 + ectx->ec_dfunc_idx; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
998 typval_T *defer_tv = STACK_TV_VAR(dfunc->df_defer_var_idx - 1); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
999 listitem_T *li; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1000 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1001 if (defer_tv->v_type != VAR_LIST) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1002 return; // no function added |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1003 for (li = defer_tv->vval.v_list->lv_first; li != NULL; li = li->li_next) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1004 { |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1005 list_T *l = li->li_tv.vval.v_list; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1006 typval_T rettv; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1007 typval_T argvars[MAX_FUNC_ARGS]; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1008 int i; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1009 listitem_T *arg_li = l->lv_first; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1010 funcexe_T funcexe; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1011 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1012 for (i = 0; i < l->lv_len - 1; ++i) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1013 { |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1014 arg_li = arg_li->li_next; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1015 argvars[i] = arg_li->li_tv; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1016 } |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1017 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1018 CLEAR_FIELD(funcexe); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1019 funcexe.fe_evaluate = TRUE; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1020 rettv.v_type = VAR_UNKNOWN; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1021 (void)call_func(l->lv_first->li_tv.vval.v_string, -1, |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1022 &rettv, l->lv_len - 1, argvars, &funcexe); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1023 clear_tv(&rettv); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1024 } |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1025 } |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1026 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1027 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 * Return from the current function. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 */ |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1030 static int |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1031 func_return(ectx_T *ectx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 int idx; |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1034 int ret_idx; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1035 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1036 + ectx->ec_dfunc_idx; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1037 int argcount = ufunc_argcount(dfunc->df_ufunc); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1038 int top = ectx->ec_frame_idx - argcount; |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
1039 estack_T *entry; |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1040 int prev_dfunc_idx = STACK_TV(ectx->ec_frame_idx |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1041 + STACK_FRAME_FUNC_OFF)->vval.v_number; |
24549
dd87d08f86de
patch 8.2.2814: Vim9: unused variable
Bram Moolenaar <Bram@vim.org>
parents:
24545
diff
changeset
|
1042 funclocal_T *floc; |
dd87d08f86de
patch 8.2.2814: Vim9: unused variable
Bram Moolenaar <Bram@vim.org>
parents:
24545
diff
changeset
|
1043 #ifdef FEAT_PROFILE |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1044 dfunc_T *prev_dfunc = ((dfunc_T *)def_functions.ga_data) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1045 + prev_dfunc_idx; |
24549
dd87d08f86de
patch 8.2.2814: Vim9: unused variable
Bram Moolenaar <Bram@vim.org>
parents:
24545
diff
changeset
|
1046 |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1047 if (do_profiling == PROF_YES) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1048 { |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1049 ufunc_T *caller = prev_dfunc->df_ufunc; |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1050 |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1051 if (dfunc->df_ufunc->uf_profiling |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1052 || (caller != NULL && caller->uf_profiling)) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1053 { |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1054 profile_may_end_func(((profinfo_T *)profile_info_ga.ga_data) |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1055 + profile_info_ga.ga_len - 1, dfunc->df_ufunc, caller); |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1056 --profile_info_ga.ga_len; |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1057 } |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1058 } |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1059 #endif |
26558
ad00a5cb005d
patch 8.2.3808: Vim9: obsolete TODO items
Bram Moolenaar <Bram@vim.org>
parents:
26534
diff
changeset
|
1060 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1061 if (dfunc->df_defer_var_idx > 0) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1062 invoke_defer_funcs(ectx); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
1063 |
26558
ad00a5cb005d
patch 8.2.3808: Vim9: obsolete TODO items
Bram Moolenaar <Bram@vim.org>
parents:
26534
diff
changeset
|
1064 // No check for uf_refcount being zero, cannot think of a way that would |
ad00a5cb005d
patch 8.2.3808: Vim9: obsolete TODO items
Bram Moolenaar <Bram@vim.org>
parents:
26534
diff
changeset
|
1065 // happen. |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
1066 --dfunc->df_ufunc->uf_calls; |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
1067 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 // execution context goes one level up |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
1069 entry = estack_pop(); |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
1070 if (entry != NULL) |
24471
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24454
diff
changeset
|
1071 current_sctx = entry->es_save_sctx; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1073 if (handle_closure_in_use(ectx, TRUE) == FAIL) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1074 return FAIL; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1075 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1076 // Clear the arguments. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1077 for (idx = top; idx < ectx->ec_frame_idx; ++idx) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1078 clear_tv(STACK_TV(idx)); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1079 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1080 // Clear local variables and temp values, but not the return value. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1081 for (idx = ectx->ec_frame_idx + STACK_FRAME_SIZE; |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
1082 idx < ectx->ec_stack.ga_len - 1; ++idx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 clear_tv(STACK_TV(idx)); |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
1084 |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1085 // The return value should be on top of the stack. However, when aborting |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1086 // it may not be there and ec_frame_idx is the top of the stack. |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1087 ret_idx = ectx->ec_stack.ga_len - 1; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1088 if (ret_idx == ectx->ec_frame_idx + STACK_FRAME_IDX_OFF) |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1089 ret_idx = 0; |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1090 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1091 if (ectx->ec_outer_ref != NULL) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1092 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1093 if (ectx->ec_outer_ref->or_outer_allocated) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1094 vim_free(ectx->ec_outer_ref->or_outer); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1095 partial_unref(ectx->ec_outer_ref->or_partial); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1096 vim_free(ectx->ec_outer_ref); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1097 } |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1098 |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
1099 // Restore the previous frame. |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
1100 ectx->ec_dfunc_idx = prev_dfunc_idx; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1101 ectx->ec_iidx = STACK_TV(ectx->ec_frame_idx |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1102 + STACK_FRAME_IIDX_OFF)->vval.v_number; |
24545
fe29b220eece
patch 8.2.2812: Vim9: still crash when using substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
24541
diff
changeset
|
1103 ectx->ec_instr = (void *)STACK_TV(ectx->ec_frame_idx |
fe29b220eece
patch 8.2.2812: Vim9: still crash when using substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
24541
diff
changeset
|
1104 + STACK_FRAME_INSTR_OFF)->vval.v_string; |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1105 ectx->ec_outer_ref = (void *)STACK_TV(ectx->ec_frame_idx |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1106 + STACK_FRAME_OUTER_OFF)->vval.v_string; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1107 floc = (void *)STACK_TV(ectx->ec_frame_idx |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1108 + STACK_FRAME_FUNCLOCAL_OFF)->vval.v_string; |
22460
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1109 // restoring ec_frame_idx must be last |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1110 ectx->ec_frame_idx = STACK_TV(ectx->ec_frame_idx |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1111 + STACK_FRAME_IDX_OFF)->vval.v_number; |
24541
df90c61c306c
patch 8.2.2810: Vim9: crash when calling a function in a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
24504
diff
changeset
|
1112 |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1113 if (floc == NULL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1114 ectx->ec_funclocal.floc_restore_cmdmod = FALSE; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1115 else |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1116 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1117 ectx->ec_funclocal = *floc; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1118 vim_free(floc); |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1119 } |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1120 |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1121 if (ret_idx > 0) |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1122 { |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1123 // Reset the stack to the position before the call, with a spot for the |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1124 // return value, moved there from above the frame. |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1125 ectx->ec_stack.ga_len = top + 1; |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1126 *STACK_TV_BOT(-1) = *STACK_TV(ret_idx); |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1127 } |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1128 else |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1129 // Reset the stack to the position before the call. |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
1130 ectx->ec_stack.ga_len = top; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1131 |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
1132 funcdepth_decrement(); |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
1133 --ex_nesting_level; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
1134 return OK; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 * Prepare arguments and rettv for calling a builtin or user function. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 static int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 call_prepare(int argcount, typval_T *argvars, ectx_T *ectx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 int idx; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 typval_T *tv; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 // Move arguments from bottom of the stack to argvars[] and add terminator. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 for (idx = 0; idx < argcount; ++idx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 argvars[idx] = *STACK_TV_BOT(idx - argcount); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 argvars[argcount].v_type = VAR_UNKNOWN; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 // Result replaces the arguments on the stack. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 if (argcount > 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 ectx->ec_stack.ga_len -= argcount - 1; |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1154 else if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 ++ectx->ec_stack.ga_len; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 // Default return value is zero. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 tv = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 tv->v_type = VAR_NUMBER; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 tv->vval.v_number = 0; |
28233
e31f1a949d4e
patch 8.2.4643: Vim9: variable may be locked unintentionally
Bram Moolenaar <Bram@vim.org>
parents:
28231
diff
changeset
|
1163 tv->v_lock = 0; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 * Call a builtin function by index. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 static int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 call_bfunc(int func_idx, int argcount, ectx_T *ectx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 typval_T argvars[MAX_FUNC_ARGS]; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 int idx; |
22736
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22715
diff
changeset
|
1176 int did_emsg_before = did_emsg; |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
1177 ectx_T *prev_ectx = current_ectx; |
25326
cfbf40f749b0
patch 8.2.3200: Vim9: hard to guess where a type error is given
Bram Moolenaar <Bram@vim.org>
parents:
25324
diff
changeset
|
1178 char *save_func_name = ectx->ec_where.wt_func_name; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 if (call_prepare(argcount, argvars, ectx) == FAIL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 return FAIL; |
25326
cfbf40f749b0
patch 8.2.3200: Vim9: hard to guess where a type error is given
Bram Moolenaar <Bram@vim.org>
parents:
25324
diff
changeset
|
1182 ectx->ec_where.wt_func_name = internal_func_name(func_idx); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
1184 // Call the builtin function. Set "current_ectx" so that when it |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
1185 // recursively invokes call_def_function() a closure context can be set. |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
1186 current_ectx = ectx; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 call_internal_func_by_idx(func_idx, argvars, STACK_TV_BOT(-1)); |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
1188 current_ectx = prev_ectx; |
25326
cfbf40f749b0
patch 8.2.3200: Vim9: hard to guess where a type error is given
Bram Moolenaar <Bram@vim.org>
parents:
25324
diff
changeset
|
1189 ectx->ec_where.wt_func_name = save_func_name; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 // Clear the arguments. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 for (idx = 0; idx < argcount; ++idx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 clear_tv(&argvars[idx]); |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20283
diff
changeset
|
1194 |
23177
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23156
diff
changeset
|
1195 if (did_emsg > did_emsg_before) |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20283
diff
changeset
|
1196 return FAIL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 * Execute a user defined function. |
23557
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
1202 * If the function is compiled this will add a stack frame and set the |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
1203 * instruction pointer at the start of the function. |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
1204 * Otherwise the function is called here. |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1205 * If "pt" is not null use "pt->pt_outer" for ec_outer_ref->or_outer. |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1206 * "iptr" can be used to replace the instruction with a more efficient one. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 static int |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1209 call_ufunc( |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1210 ufunc_T *ufunc, |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1211 partial_T *pt, |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1212 int argcount, |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1213 ectx_T *ectx, |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1214 isn_T *iptr, |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1215 dict_T *selfdict) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 typval_T argvars[MAX_FUNC_ARGS]; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 funcexe_T funcexe; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 int error; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 int idx; |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
1221 int did_emsg_before = did_emsg; |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1222 compiletype_T compile_type = get_compile_type(ufunc); |
24932
afaa7f3aae56
patch 8.2.3003: Vim9: closure compiled with wrong compile type
Bram Moolenaar <Bram@vim.org>
parents:
24918
diff
changeset
|
1223 |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
1224 if (func_needs_compiling(ufunc, compile_type) |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
1225 && compile_def_function(ufunc, FALSE, compile_type, NULL) |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
1226 == FAIL) |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20433
diff
changeset
|
1227 return FAIL; |
20943
1693ca876049
patch 8.2.1023: Vim9: redefining a function uses a new index every time
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
1228 if (ufunc->uf_def_status == UF_COMPILED) |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1229 { |
23254
4b7e996354e0
patch 8.2.2173: Vim9: get internal error when assigning to undefined variable
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
1230 error = check_user_func_argcount(ufunc, argcount); |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1231 if (error != FCERR_UNKNOWN) |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1232 { |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1233 if (error == FCERR_TOOMANY) |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1234 semsg(_(e_too_many_arguments_for_function_str), |
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1235 printable_func_name(ufunc)); |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1236 else |
26602
fac6673086df
patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26560
diff
changeset
|
1237 semsg(_(e_not_enough_arguments_for_function_str), |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1238 printable_func_name(ufunc)); |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1239 return FAIL; |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1240 } |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1241 |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1242 // The function has been compiled, can call it quickly. For a function |
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1243 // that was defined later: we can call it directly next time. |
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1244 if (iptr != NULL) |
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1245 { |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
1246 delete_instr(iptr); |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1247 iptr->isn_type = ISN_DCALL; |
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1248 iptr->isn_arg.dfunc.cdf_idx = ufunc->uf_dfunc_idx; |
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1249 iptr->isn_arg.dfunc.cdf_argcount = argcount; |
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1250 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1251 return call_dfunc(ufunc->uf_dfunc_idx, pt, argcount, ectx); |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1252 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 if (call_prepare(argcount, argvars, ectx) == FAIL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 return FAIL; |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19981
diff
changeset
|
1256 CLEAR_FIELD(funcexe); |
26534
28745eec1dda
patch 8.2.3796: the funcexe_T struct members are not named consistently
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1257 funcexe.fe_evaluate = TRUE; |
28745eec1dda
patch 8.2.3796: the funcexe_T struct members are not named consistently
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1258 funcexe.fe_selfdict = selfdict != NULL ? selfdict : dict_stack_get_dict(); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 // Call the user function. Result goes in last position on the stack. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 error = call_user_func_check(ufunc, argcount, argvars, |
26534
28745eec1dda
patch 8.2.3796: the funcexe_T struct members are not named consistently
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1262 STACK_TV_BOT(-1), &funcexe, funcexe.fe_selfdict); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 // Clear the arguments. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 for (idx = 0; idx < argcount; ++idx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 clear_tv(&argvars[idx]); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 if (error != FCERR_NONE) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 { |
30594
586b5b3aacf9
patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents:
30564
diff
changeset
|
1270 user_func_error(error, printable_func_name(ufunc), |
586b5b3aacf9
patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents:
30564
diff
changeset
|
1271 funcexe.fe_found_var); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 } |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
1274 if (did_emsg > did_emsg_before) |
21757
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1275 // Error other than from calling the function itself. |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1276 return FAIL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 /* |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1281 * If command modifiers were applied restore them. |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1282 */ |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1283 static void |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1284 may_restore_cmdmod(funclocal_T *funclocal) |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1285 { |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1286 if (funclocal->floc_restore_cmdmod) |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1287 { |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1288 cmdmod.cmod_filter_regmatch.regprog = NULL; |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1289 undo_cmdmod(&cmdmod); |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1290 cmdmod = funclocal->floc_save_cmdmod; |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1291 funclocal->floc_restore_cmdmod = FALSE; |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1292 } |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1293 } |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1294 |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
1295 /* |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1296 * Return TRUE if an error was given (not caught in try/catch) or CTRL-C was |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1297 * pressed. |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1298 */ |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1299 static int |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1300 vim9_aborting(int prev_uncaught_emsg) |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1301 { |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1302 return uncaught_emsg > prev_uncaught_emsg || got_int || did_throw; |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1303 } |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1304 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1305 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 * Execute a function by "name". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 * This can be a builtin function or a user function. |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1308 * "iptr" can be used to replace the instruction with a more efficient one. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 * Returns FAIL if not found without an error message. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 static int |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1312 call_by_name( |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1313 char_u *name, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1314 int argcount, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1315 ectx_T *ectx, |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1316 isn_T *iptr, |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1317 dict_T *selfdict) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 ufunc_T *ufunc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 if (builtin_function(name, -1)) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 int func_idx = find_internal_func(name); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27841
diff
changeset
|
1325 if (func_idx < 0) // Impossible? |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 return FAIL; |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
1327 if (check_internal_func(func_idx, argcount) < 0) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 return call_bfunc(func_idx, argcount, ectx); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
1332 ufunc = find_func(name, FALSE); |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1333 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1334 if (ufunc == NULL) |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1335 { |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1336 int prev_uncaught_emsg = uncaught_emsg; |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1337 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1338 if (script_autoload(name, TRUE)) |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1339 // loaded a package, search for the function again |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
1340 ufunc = find_func(name, FALSE); |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1341 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
1342 if (vim9_aborting(prev_uncaught_emsg)) |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1343 return FAIL; // bail out if loading the script caused an error |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1344 } |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
1345 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 if (ufunc != NULL) |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1347 { |
25543
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
1348 if (ufunc->uf_arg_types != NULL || ufunc->uf_va_type != NULL) |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1349 { |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1350 int i; |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1351 typval_T *argv = STACK_TV_BOT(0) - argcount; |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1352 |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1353 // The function can change at runtime, check that the argument |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1354 // types are correct. |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1355 for (i = 0; i < argcount; ++i) |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1356 { |
24077
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
1357 type_T *type = NULL; |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
1358 |
25543
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
1359 if (i < ufunc->uf_args.ga_len && ufunc->uf_arg_types != NULL) |
24077
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
1360 type = ufunc->uf_arg_types[i]; |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
1361 else if (ufunc->uf_va_type != NULL) |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
1362 type = ufunc->uf_va_type->tt_member; |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1363 if (type != NULL && check_typval_arg_type(type, |
25326
cfbf40f749b0
patch 8.2.3200: Vim9: hard to guess where a type error is given
Bram Moolenaar <Bram@vim.org>
parents:
25324
diff
changeset
|
1364 &argv[i], NULL, i + 1) == FAIL) |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1365 return FAIL; |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1366 } |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1367 } |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1368 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1369 return call_ufunc(ufunc, NULL, argcount, ectx, iptr, selfdict); |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
1370 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 static int |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1376 call_partial( |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1377 typval_T *tv, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1378 int argcount_arg, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1379 ectx_T *ectx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 { |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1381 int argcount = argcount_arg; |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
1382 char_u *name = NULL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 int called_emsg_before = called_emsg; |
23582
b875bbd517a6
patch 8.2.2333: Vim9: warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
23580
diff
changeset
|
1384 int res = FAIL; |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1385 dict_T *selfdict = NULL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 if (tv->v_type == VAR_PARTIAL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 { |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1389 partial_T *pt = tv->vval.v_partial; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1390 int i; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1391 |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1392 if (pt->pt_argc > 0) |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1393 { |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1394 // Make space for arguments from the partial, shift the "argcount" |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1395 // arguments up. |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1396 if (GA_GROW_FAILS(&ectx->ec_stack, pt->pt_argc)) |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1397 return FAIL; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1398 for (i = 1; i <= argcount; ++i) |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1399 *STACK_TV_BOT(-i + pt->pt_argc) = *STACK_TV_BOT(-i); |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1400 ectx->ec_stack.ga_len += pt->pt_argc; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1401 argcount += pt->pt_argc; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1402 |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1403 // copy the arguments from the partial onto the stack |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1404 for (i = 0; i < pt->pt_argc; ++i) |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1405 copy_tv(&pt->pt_argv[i], STACK_TV_BOT(-argcount + i)); |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1406 } |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1407 selfdict = pt->pt_dict; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 if (pt->pt_func != NULL) |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1410 return call_ufunc(pt->pt_func, pt, argcount, ectx, NULL, selfdict); |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1411 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 name = pt->pt_name; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 } |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
1414 else if (tv->v_type == VAR_FUNC) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 name = tv->vval.v_string; |
21983
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1416 if (name != NULL) |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1417 { |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1418 char_u fname_buf[FLEN_FIXED + 1]; |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1419 char_u *tofree = NULL; |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1420 int error = FCERR_NONE; |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1421 char_u *fname; |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1422 |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1423 // May need to translate <SNR>123_ to K_SNR. |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1424 fname = fname_trans_sid(name, fname_buf, &tofree, &error); |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1425 if (error != FCERR_NONE) |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1426 res = FAIL; |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1427 else |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1428 res = call_by_name(fname, argcount, ectx, NULL, selfdict); |
21983
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1429 vim_free(tofree); |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1430 } |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1431 |
23582
b875bbd517a6
patch 8.2.2333: Vim9: warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
23580
diff
changeset
|
1432 if (res == FAIL) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 if (called_emsg == called_emsg_before) |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1435 emsg_funcname(e_unknown_function_str, |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20283
diff
changeset
|
1436 name == NULL ? (char_u *)"[unknown]" : name); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 /* |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1443 * Check if "lock" is VAR_LOCKED or VAR_FIXED. If so give an error and return |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1444 * TRUE. |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1445 */ |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1446 static int |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1447 error_if_locked(int lock, char *error) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1448 { |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1449 if (lock & (VAR_LOCKED | VAR_FIXED)) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1450 { |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1451 emsg(_(error)); |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1452 return TRUE; |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1453 } |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1454 return FALSE; |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1455 } |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1456 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1457 /* |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1458 * Give an error if "tv" is not a number and return FAIL. |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1459 */ |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1460 static int |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1461 check_for_number(typval_T *tv) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1462 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1463 if (tv->v_type != VAR_NUMBER) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1464 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1465 semsg(_(e_expected_str_but_got_str), |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1466 vartype_name(VAR_NUMBER), vartype_name(tv->v_type)); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1467 return FAIL; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1468 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1469 return OK; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1470 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1471 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1472 /* |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1473 * Store "tv" in variable "name". |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1474 * This is for s: and g: variables. |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1475 */ |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1476 static void |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1477 store_var(char_u *name, typval_T *tv) |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1478 { |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1479 funccal_entry_T entry; |
24293
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1480 int flags = ASSIGN_DECL; |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1481 |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1482 if (tv->v_lock) |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1483 flags |= ASSIGN_CONST; |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1484 save_funccal(&entry); |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26891
diff
changeset
|
1485 set_var_const(name, 0, NULL, tv, FALSE, flags, 0); |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1486 restore_funccal(); |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1487 } |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1488 |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1489 /* |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1490 * Convert "tv" to a string. |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1491 * Return FAIL if not allowed. |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1492 */ |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1493 static int |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1494 do_2string(typval_T *tv, int is_2string_any, int tolerant) |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1495 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1496 if (tv->v_type != VAR_STRING) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1497 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1498 char_u *str; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1499 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1500 if (is_2string_any) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1501 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1502 switch (tv->v_type) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1503 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1504 case VAR_SPECIAL: |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1505 case VAR_BOOL: |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1506 case VAR_NUMBER: |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1507 case VAR_FLOAT: |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1508 case VAR_BLOB: break; |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1509 |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1510 case VAR_LIST: |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1511 if (tolerant) |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1512 { |
24806
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1513 char_u *s, *e, *p; |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1514 garray_T ga; |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1515 |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1516 ga_init2(&ga, sizeof(char_u *), 1); |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1517 |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1518 // Convert to NL separated items, then |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1519 // escape the items and replace the NL with |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1520 // a space. |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1521 str = typval2string(tv, TRUE); |
24806
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1522 if (str == NULL) |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1523 return FAIL; |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1524 s = str; |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1525 while ((e = vim_strchr(s, '\n')) != NULL) |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1526 { |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1527 *e = NUL; |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25814
diff
changeset
|
1528 p = vim_strsave_fnameescape(s, |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25814
diff
changeset
|
1529 VSE_NONE); |
24806
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1530 if (p != NULL) |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1531 { |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1532 ga_concat(&ga, p); |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1533 ga_concat(&ga, (char_u *)" "); |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1534 vim_free(p); |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1535 } |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1536 s = e + 1; |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1537 } |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1538 vim_free(str); |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1539 clear_tv(tv); |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1540 tv->v_type = VAR_STRING; |
24806
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1541 tv->vval.v_string = ga.ga_data; |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1542 return OK; |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1543 } |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1544 // FALLTHROUGH |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1545 default: to_string_error(tv->v_type); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1546 return FAIL; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1547 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1548 } |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23735
diff
changeset
|
1549 str = typval_tostring(tv, TRUE); |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1550 clear_tv(tv); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1551 tv->v_type = VAR_STRING; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1552 tv->vval.v_string = str; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1553 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1554 return OK; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1555 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1556 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1557 /* |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1558 * When the value of "sv" is a null list of dict, allocate it. |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1559 */ |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1560 static void |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
1561 allocate_if_null(svar_T *sv) |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1562 { |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
1563 typval_T *tv = sv->sv_tv; |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
1564 |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1565 switch (tv->v_type) |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1566 { |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1567 case VAR_LIST: |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
1568 if (tv->vval.v_list == NULL && sv->sv_type != &t_list_empty) |
23839
23d6ead591c1
patch 8.2.2461: Coverity warns for unchecked return value
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
1569 (void)rettv_list_alloc(tv); |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1570 break; |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1571 case VAR_DICT: |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
1572 if (tv->vval.v_dict == NULL && sv->sv_type != &t_dict_empty) |
23839
23d6ead591c1
patch 8.2.2461: Coverity warns for unchecked return value
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
1573 (void)rettv_dict_alloc(tv); |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1574 break; |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
1575 case VAR_BLOB: |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
1576 if (tv->vval.v_blob == NULL && sv->sv_type != &t_blob_null) |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
1577 (void)rettv_blob_alloc(tv); |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
1578 break; |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1579 default: |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1580 break; |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1581 } |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1582 } |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
1583 |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1584 /* |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1585 * Return the character "str[index]" where "index" is the character index, |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1586 * including composing characters. |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1587 * If "index" is out of range NULL is returned. |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1588 */ |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1589 char_u * |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1590 char_from_string(char_u *str, varnumber_T index) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1591 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1592 size_t nbyte = 0; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1593 varnumber_T nchar = index; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1594 size_t slen; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1595 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1596 if (str == NULL) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1597 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1598 slen = STRLEN(str); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1599 |
24226
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1600 // Do the same as for a list: a negative index counts from the end. |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1601 // Optimization to check the first byte to be below 0x80 (and no composing |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1602 // character follows) makes this a lot faster. |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1603 if (index < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1604 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1605 int clen = 0; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1606 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1607 for (nbyte = 0; nbyte < slen; ++clen) |
24226
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1608 { |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1609 if (str[nbyte] < 0x80 && str[nbyte + 1] < 0x80) |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1610 ++nbyte; |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1611 else if (enc_utf8) |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1612 nbyte += utfc_ptr2len(str + nbyte); |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1613 else |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1614 nbyte += mb_ptr2len(str + nbyte); |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1615 } |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1616 nchar = clen + index; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1617 if (nchar < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1618 // unlike list: index out of range results in empty string |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1619 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1620 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1621 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1622 for (nbyte = 0; nchar > 0 && nbyte < slen; --nchar) |
24226
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1623 { |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1624 if (str[nbyte] < 0x80 && str[nbyte + 1] < 0x80) |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1625 ++nbyte; |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1626 else if (enc_utf8) |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1627 nbyte += utfc_ptr2len(str + nbyte); |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1628 else |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1629 nbyte += mb_ptr2len(str + nbyte); |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1630 } |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1631 if (nbyte >= slen) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1632 return NULL; |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1633 return vim_strnsave(str + nbyte, mb_ptr2len(str + nbyte)); |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1634 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1635 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1636 /* |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1637 * Get the byte index for character index "idx" in string "str" with length |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1638 * "str_len". Composing characters are included. |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1639 * If going over the end return "str_len". |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1640 * If "idx" is negative count from the end, -1 is the last character. |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1641 * When going over the start return -1. |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1642 */ |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1643 static long |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1644 char_idx2byte(char_u *str, size_t str_len, varnumber_T idx) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1645 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1646 varnumber_T nchar = idx; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1647 size_t nbyte = 0; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1648 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1649 if (nchar >= 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1650 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1651 while (nchar > 0 && nbyte < str_len) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1652 { |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1653 nbyte += mb_ptr2len(str + nbyte); |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1654 --nchar; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1655 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1656 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1657 else |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1658 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1659 nbyte = str_len; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1660 while (nchar < 0 && nbyte > 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1661 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1662 --nbyte; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1663 nbyte -= mb_head_off(str, str + nbyte); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1664 ++nchar; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1665 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1666 if (nchar < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1667 return -1; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1668 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1669 return (long)nbyte; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1670 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1671 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1672 /* |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1673 * Return the slice "str[first : last]" using character indexes. Composing |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1674 * characters are included. |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
1675 * "exclusive" is TRUE for slice(). |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1676 * Return NULL when the result is empty. |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1677 */ |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1678 char_u * |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
1679 string_slice(char_u *str, varnumber_T first, varnumber_T last, int exclusive) |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1680 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1681 long start_byte, end_byte; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1682 size_t slen; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1683 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1684 if (str == NULL) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1685 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1686 slen = STRLEN(str); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1687 start_byte = char_idx2byte(str, slen, first); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1688 if (start_byte < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1689 start_byte = 0; // first index very negative: use zero |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
1690 if ((last == -1 && !exclusive) || last == VARNUM_MAX) |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1691 end_byte = (long)slen; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1692 else |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1693 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1694 end_byte = char_idx2byte(str, slen, last); |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
1695 if (!exclusive && end_byte >= 0 && end_byte < (long)slen) |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1696 // end index is inclusive |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1697 end_byte += mb_ptr2len(str + end_byte); |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1698 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1699 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1700 if (start_byte >= (long)slen || end_byte <= start_byte) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1701 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1702 return vim_strnsave(str + start_byte, end_byte - start_byte); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1703 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1704 |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1705 /* |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1706 * Get a script variable for ISN_STORESCRIPT and ISN_LOADSCRIPT. |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1707 * When "dfunc_idx" is negative don't give an error. |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1708 * Returns NULL for an error. |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1709 */ |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1710 static svar_T * |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1711 get_script_svar(scriptref_T *sref, int dfunc_idx) |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1712 { |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1713 scriptitem_T *si = SCRIPT_ITEM(sref->sref_sid); |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1714 dfunc_T *dfunc = dfunc_idx < 0 ? NULL |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1715 : ((dfunc_T *)def_functions.ga_data) + dfunc_idx; |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1716 svar_T *sv; |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1717 |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1718 if (sref->sref_seq != si->sn_script_seq) |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1719 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1720 // The script was reloaded after the function was compiled, the |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1721 // script_idx may not be valid. |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1722 if (dfunc != NULL) |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1723 semsg(_(e_script_variable_invalid_after_reload_in_function_str), |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1724 printable_func_name(dfunc->df_ufunc)); |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1725 return NULL; |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1726 } |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1727 sv = ((svar_T *)si->sn_var_vals.ga_data) + sref->sref_idx; |
30192
9f8b1f584395
patch 9.0.0432: crash when using for loop variable in closure
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
1728 if (sv->sv_name == NULL) |
9f8b1f584395
patch 9.0.0432: crash when using for loop variable in closure
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
1729 { |
9f8b1f584395
patch 9.0.0432: crash when using for loop variable in closure
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
1730 if (dfunc != NULL) |
9f8b1f584395
patch 9.0.0432: crash when using for loop variable in closure
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
1731 emsg(_(e_script_variable_was_deleted)); |
9f8b1f584395
patch 9.0.0432: crash when using for loop variable in closure
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
1732 return NULL; |
9f8b1f584395
patch 9.0.0432: crash when using for loop variable in closure
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
1733 } |
25425
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25350
diff
changeset
|
1734 if (!equal_type(sv->sv_type, sref->sref_type, 0)) |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1735 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1736 if (dfunc != NULL) |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1737 emsg(_(e_script_variable_type_changed)); |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1738 return NULL; |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1739 } |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
1740 |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1741 if ((sv->sv_flags & SVFLAG_EXPORTED) == 0 |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1742 && sref->sref_sid != current_sctx.sc_sid) |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
1743 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
1744 if (dfunc != NULL) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
1745 semsg(_(e_item_not_exported_in_script_str), sv->sv_name); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
1746 return NULL; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
1747 } |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1748 return sv; |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1749 } |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1750 |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1751 /* |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1752 * Function passed to do_cmdline() for splitting a script joined by NL |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1753 * characters. |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1754 */ |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1755 static char_u * |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1756 get_split_sourceline( |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1757 int c UNUSED, |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1758 void *cookie, |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1759 int indent UNUSED, |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1760 getline_opt_T options UNUSED) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1761 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1762 source_cookie_T *sp = (source_cookie_T *)cookie; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1763 char_u *p; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1764 char_u *line; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1765 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1766 p = vim_strchr(sp->nextline, '\n'); |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1767 if (p == NULL) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1768 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1769 line = vim_strsave(sp->nextline); |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1770 sp->nextline += STRLEN(sp->nextline); |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1771 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1772 else |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1773 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1774 line = vim_strnsave(sp->nextline, p - sp->nextline); |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1775 sp->nextline = p + 1; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1776 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1777 return line; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1778 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1779 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1780 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 * Execute a function by "name". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 * This can be a builtin function, user function or a funcref. |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
1783 * "iptr" can be used to replace the instruction with a more efficient one. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 static int |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1786 call_eval_func( |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1787 char_u *name, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1788 int argcount, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1789 ectx_T *ectx, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1790 isn_T *iptr) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 { |
21757
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1792 int called_emsg_before = called_emsg; |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1793 int res; |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1794 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1795 res = call_by_name(name, argcount, ectx, iptr, NULL); |
21757
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1796 if (res == FAIL && called_emsg == called_emsg_before) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 { |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1798 dictitem_T *v; |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1799 |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1800 v = find_var(name, NULL, FALSE); |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1801 if (v == NULL || (v->di_tv.v_type != VAR_PARTIAL |
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1802 && v->di_tv.v_type != VAR_FUNC)) |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1803 { |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28253
diff
changeset
|
1804 emsg_funcname(e_unknown_function_str, name); |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1805 return FAIL; |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1806 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1807 return call_partial(&v->di_tv, argcount, ectx); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 } |
21757
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1809 return res; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 /* |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1813 * When a function reference is used, fill a partial with the information |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1814 * needed, especially when it is used as a closure. |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1815 */ |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1816 int |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
1817 fill_partial_and_closure( |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1818 partial_T *pt, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1819 ufunc_T *ufunc, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1820 loopvarinfo_T *lvi, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1821 ectx_T *ectx) |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1822 { |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1823 pt->pt_func = ufunc; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1824 pt->pt_refcount = 1; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1825 |
23699
317018f62643
patch 8.2.2391: memory leak when creating a global function with closure
Bram Moolenaar <Bram@vim.org>
parents:
23697
diff
changeset
|
1826 if (ufunc->uf_flags & FC_CLOSURE) |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1827 { |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1828 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1829 + ectx->ec_dfunc_idx; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1830 |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
1831 // The closure may need to find arguments and local variables of the |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
1832 // current function in the stack. |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1833 pt->pt_outer.out_stack = &ectx->ec_stack; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1834 pt->pt_outer.out_frame_idx = ectx->ec_frame_idx; |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1835 if (ectx->ec_outer_ref != NULL) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1836 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1837 // The current context already has a context, link to that one. |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1838 pt->pt_outer.out_up = ectx->ec_outer_ref->or_outer; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1839 if (ectx->ec_outer_ref->or_partial != NULL) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1840 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1841 pt->pt_outer.out_up_partial = ectx->ec_outer_ref->or_partial; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1842 ++pt->pt_outer.out_up_partial->pt_refcount; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1843 } |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1844 } |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1845 |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1846 if (lvi != NULL) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1847 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1848 int depth; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1849 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1850 // The closure may need to find variables defined inside a loop, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1851 // for every nested loop. A new reference is made every time, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1852 // ISN_ENDLOOP will check if they are actually used. |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1853 for (depth = 0; depth < lvi->lvi_depth; ++depth) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1854 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1855 pt->pt_outer.out_loop[depth].stack = &ectx->ec_stack; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1856 pt->pt_outer.out_loop[depth].var_idx = ectx->ec_frame_idx |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1857 + STACK_FRAME_SIZE + lvi->lvi_loop[depth].var_idx; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1858 pt->pt_outer.out_loop[depth].var_count = |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1859 lvi->lvi_loop[depth].var_count; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1860 } |
30423
221cca379bd5
patch 9.0.0547: looping over empty out_loop[] entries
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
1861 pt->pt_outer.out_loop_size = lvi->lvi_depth; |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
1862 } |
30423
221cca379bd5
patch 9.0.0547: looping over empty out_loop[] entries
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
1863 else |
221cca379bd5
patch 9.0.0547: looping over empty out_loop[] entries
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
1864 pt->pt_outer.out_loop_size = 0; |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
1865 |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
1866 // If the function currently executing returns and the closure is still |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
1867 // being referenced, we need to make a copy of the context (arguments |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
1868 // and local variables) so that the closure can use it later. |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1869 // Store a reference to the partial so we can handle that. |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1870 if (GA_GROW_FAILS(&ectx->ec_funcrefs, 1)) |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1871 { |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1872 vim_free(pt); |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1873 return FAIL; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1874 } |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1875 // Extra variable keeps the count of closures created in the current |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1876 // function call. |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1877 ++(((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_frame_idx |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1878 + STACK_FRAME_SIZE + dfunc->df_varcount)->vval.v_number; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1879 |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
1880 ((partial_T **)ectx->ec_funcrefs.ga_data)[ectx->ec_funcrefs.ga_len] |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
1881 = pt; |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1882 ++pt->pt_refcount; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1883 ++ectx->ec_funcrefs.ga_len; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1884 } |
23699
317018f62643
patch 8.2.2391: memory leak when creating a global function with closure
Bram Moolenaar <Bram@vim.org>
parents:
23697
diff
changeset
|
1885 ++ufunc->uf_refcount; |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1886 return OK; |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1887 } |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1888 |
25605
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1889 /* |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1890 * Execute iptr->isn_arg.string as an Ex command. |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1891 */ |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1892 static int |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1893 exec_command(isn_T *iptr) |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1894 { |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1895 source_cookie_T cookie; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1896 |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1897 SOURCING_LNUM = iptr->isn_lnum; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1898 // Pass getsourceline to get an error for a missing ":end" |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1899 // command. |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1900 CLEAR_FIELD(cookie); |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1901 cookie.sourcing_lnum = iptr->isn_lnum - 1; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1902 if (do_cmdline(iptr->isn_arg.string, |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1903 getsourceline, &cookie, |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1904 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED) == FAIL |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1905 || did_emsg) |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1906 return FAIL; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1907 return OK; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1908 } |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1909 |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1910 /* |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1911 * If script "sid" is not loaded yet then load it now. |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1912 * Caller must make sure "sid" is a valid script ID. |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1913 * "loaded" is set to TRUE if the script had to be loaded. |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1914 * Returns FAIL if loading fails, OK if already loaded or loaded now. |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1915 */ |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1916 int |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1917 may_load_script(int sid, int *loaded) |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1918 { |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1919 scriptitem_T *si = SCRIPT_ITEM(sid); |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1920 |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1921 if (si->sn_state == SN_STATE_NOT_LOADED) |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1922 { |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1923 *loaded = TRUE; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1924 if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL) == FAIL) |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1925 { |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1926 semsg(_(e_cant_open_file_str), si->sn_name); |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1927 return FAIL; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1928 } |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1929 } |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1930 return OK; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1931 } |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
1932 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1933 // used for v_instr of typval of VAR_INSTR |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1934 struct instr_S { |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1935 ectx_T *instr_ectx; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1936 isn_T *instr_instr; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1937 }; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1938 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1939 // used for substitute_instr |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1940 typedef struct subs_expr_S { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1941 ectx_T *subs_ectx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1942 isn_T *subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1943 int subs_status; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1944 } subs_expr_T; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1946 // Set when calling do_debug(). |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1947 static ectx_T *debug_context = NULL; |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1948 static int debug_var_count; |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1949 |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1950 /* |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1951 * When debugging lookup "name" and return the typeval. |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1952 * When not found return NULL. |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1953 */ |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1954 typval_T * |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1955 lookup_debug_var(char_u *name) |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1956 { |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1957 int idx; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1958 dfunc_T *dfunc; |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1959 ufunc_T *ufunc; |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1960 ectx_T *ectx = debug_context; |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1961 int varargs_off; |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1962 |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1963 if (ectx == NULL) |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1964 return NULL; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1965 dfunc = ((dfunc_T *)def_functions.ga_data) + ectx->ec_dfunc_idx; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1966 |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1967 // Go through the local variable names, from last to first. |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1968 for (idx = debug_var_count - 1; idx >= 0; --idx) |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1969 { |
28033
73f4d1e479f2
patch 8.2.4541: Crash in debugger when a variable is not available
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1970 char_u *varname = ((char_u **)dfunc->df_var_names.ga_data)[idx]; |
73f4d1e479f2
patch 8.2.4541: Crash in debugger when a variable is not available
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1971 |
73f4d1e479f2
patch 8.2.4541: Crash in debugger when a variable is not available
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1972 // the variable name may be NULL when not available in this block |
73f4d1e479f2
patch 8.2.4541: Crash in debugger when a variable is not available
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1973 if (varname != NULL && STRCMP(varname, name) == 0) |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1974 return STACK_TV_VAR(idx); |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1975 } |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1976 |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1977 // Go through argument names. |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1978 ufunc = dfunc->df_ufunc; |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1979 varargs_off = ufunc->uf_va_name == NULL ? 0 : 1; |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1980 for (idx = 0; idx < ufunc->uf_args.ga_len; ++idx) |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1981 if (STRCMP(((char_u **)(ufunc->uf_args.ga_data))[idx], name) == 0) |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1982 return STACK_TV(ectx->ec_frame_idx - ufunc->uf_args.ga_len |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1983 - varargs_off + idx); |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1984 if (ufunc->uf_va_name != NULL && STRCMP(ufunc->uf_va_name, name) == 0) |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1985 return STACK_TV(ectx->ec_frame_idx - 1); |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1986 |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1987 return NULL; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1988 } |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1989 |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1990 /* |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1991 * Return TRUE if there might be a breakpoint in "ufunc", which is when a |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1992 * breakpoint was set in that function or when there is any expression. |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1993 */ |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1994 int |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1995 may_break_in_function(ufunc_T *ufunc) |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1996 { |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1997 return ufunc->uf_has_breakpoint || debug_has_expr_breakpoint(); |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1998 } |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1999 |
24952
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2000 static void |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2001 handle_debug(isn_T *iptr, ectx_T *ectx) |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2002 { |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2003 char_u *line; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2004 ufunc_T *ufunc = (((dfunc_T *)def_functions.ga_data) |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2005 + ectx->ec_dfunc_idx)->df_ufunc; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2006 isn_T *ni; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2007 int end_lnum = iptr->isn_lnum; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2008 garray_T ga; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2009 int lnum; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2010 |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2011 if (ex_nesting_level > debug_break_level) |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2012 { |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2013 linenr_T breakpoint; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2014 |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
2015 if (!may_break_in_function(ufunc)) |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2016 return; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2017 |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2018 // check for the next breakpoint if needed |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2019 breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, |
25004
70f55a30f03c
patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2020 iptr->isn_arg.debug.dbg_break_lnum); |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2021 if (breakpoint <= 0 || breakpoint > iptr->isn_lnum) |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2022 return; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2023 } |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
2024 |
24952
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2025 SOURCING_LNUM = iptr->isn_lnum; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2026 debug_context = ectx; |
25004
70f55a30f03c
patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2027 debug_var_count = iptr->isn_arg.debug.dbg_var_names_len; |
24952
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2028 |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2029 for (ni = iptr + 1; ni->isn_type != ISN_FINISH; ++ni) |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2030 if (ni->isn_type == ISN_DEBUG |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2031 || ni->isn_type == ISN_RETURN |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2032 || ni->isn_type == ISN_RETURN_VOID) |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2033 { |
26252
3d92646fe6c8
patch 8.2.3657: Vim9: debug text misses one line of return statement
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
2034 end_lnum = ni->isn_lnum + (ni->isn_type == ISN_DEBUG ? 0 : 1); |
24952
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2035 break; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2036 } |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2037 |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2038 if (end_lnum > iptr->isn_lnum) |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2039 { |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2040 ga_init2(&ga, sizeof(char_u *), 10); |
26698
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26672
diff
changeset
|
2041 for (lnum = iptr->isn_lnum; lnum < end_lnum |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26672
diff
changeset
|
2042 && lnum <= ufunc->uf_lines.ga_len; ++lnum) |
24960
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2043 { |
25159
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
2044 char_u *p = ((char_u **)ufunc->uf_lines.ga_data)[lnum - 1]; |
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
2045 |
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
2046 if (p == NULL) |
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
2047 continue; // left over from continuation line |
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
2048 p = skipwhite(p); |
24960
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2049 if (*p == '#') |
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2050 break; |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2051 if (GA_GROW_OK(&ga, 1)) |
24960
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2052 ((char_u **)(ga.ga_data))[ga.ga_len++] = p; |
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2053 if (STRNCMP(p, "def ", 4) == 0) |
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2054 break; |
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
2055 } |
24952
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2056 line = ga_concat_strings(&ga, " "); |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2057 vim_free(ga.ga_data); |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2058 } |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2059 else |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2060 line = ((char_u **)ufunc->uf_lines.ga_data)[iptr->isn_lnum - 1]; |
24954
9b7fac4c70a0
patch 8.2.3014: Coverity warns for freeing static string
Bram Moolenaar <Bram@vim.org>
parents:
24952
diff
changeset
|
2061 |
9b7fac4c70a0
patch 8.2.3014: Coverity warns for freeing static string
Bram Moolenaar <Bram@vim.org>
parents:
24952
diff
changeset
|
2062 do_debug(line == NULL ? (char_u *)"[empty]" : line); |
24952
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2063 debug_context = NULL; |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2064 |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2065 if (end_lnum > iptr->isn_lnum) |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2066 vim_free(line); |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2067 } |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
2068 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2069 /* |
27565
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
2070 * Store a value in a list, dict or blob variable. |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2071 * Returns OK, FAIL or NOTDONE (uncatchable error). |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2072 */ |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2073 static int |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2074 execute_storeindex(isn_T *iptr, ectx_T *ectx) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2075 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2076 vartype_T dest_type = iptr->isn_arg.vartype; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2077 typval_T *tv; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2078 typval_T *tv_idx = STACK_TV_BOT(-2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2079 typval_T *tv_dest = STACK_TV_BOT(-1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2080 int status = OK; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2081 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2082 // Stack contains: |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2083 // -3 value to be stored |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2084 // -2 index |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2085 // -1 dict or list |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2086 tv = STACK_TV_BOT(-3); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2087 SOURCING_LNUM = iptr->isn_lnum; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2088 if (dest_type == VAR_ANY) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2089 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2090 dest_type = tv_dest->v_type; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2091 if (dest_type == VAR_DICT) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2092 status = do_2string(tv_idx, TRUE, FALSE); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2093 else if (dest_type == VAR_LIST && tv_idx->v_type != VAR_NUMBER) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2094 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2095 emsg(_(e_number_expected)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2096 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2097 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2098 } |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2099 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2100 if (status == OK) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2101 { |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2102 if (dest_type == VAR_LIST) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2103 { |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2104 long lidx = (long)tv_idx->vval.v_number; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2105 list_T *list = tv_dest->vval.v_list; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2106 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2107 if (list == NULL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2108 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2109 emsg(_(e_list_not_set)); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2110 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2111 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2112 if (lidx < 0 && list->lv_len + lidx >= 0) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2113 // negative index is relative to the end |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2114 lidx = list->lv_len + lidx; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2115 if (lidx < 0 || lidx > list->lv_len) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2116 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2117 semsg(_(e_list_index_out_of_range_nr), lidx); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2118 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2119 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2120 if (lidx < list->lv_len) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2121 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2122 listitem_T *li = list_find(list, lidx); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2123 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2124 if (error_if_locked(li->li_tv.v_lock, |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2125 e_cannot_change_locked_list_item)) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2126 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2127 // overwrite existing list item |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2128 clear_tv(&li->li_tv); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2129 li->li_tv = *tv; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2130 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2131 else |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2132 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2133 if (error_if_locked(list->lv_lock, e_cannot_change_locked_list)) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2134 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2135 // append to list, only fails when out of memory |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2136 if (list_append_tv(list, tv) == FAIL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2137 return NOTDONE; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2138 clear_tv(tv); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2139 } |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2140 } |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2141 else if (dest_type == VAR_DICT) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2142 { |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2143 char_u *key = tv_idx->vval.v_string; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2144 dict_T *dict = tv_dest->vval.v_dict; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2145 dictitem_T *di; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2146 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2147 SOURCING_LNUM = iptr->isn_lnum; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2148 if (dict == NULL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2149 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2150 emsg(_(e_dictionary_not_set)); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2151 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2152 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2153 if (key == NULL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2154 key = (char_u *)""; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2155 di = dict_find(dict, key, -1); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2156 if (di != NULL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2157 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2158 if (error_if_locked(di->di_tv.v_lock, |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2159 e_cannot_change_dict_item)) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2160 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2161 // overwrite existing value |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2162 clear_tv(&di->di_tv); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2163 di->di_tv = *tv; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2164 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2165 else |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2166 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2167 if (error_if_locked(dict->dv_lock, e_cannot_change_dict)) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2168 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2169 // add to dict, only fails when out of memory |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2170 if (dict_add_tv(dict, (char *)key, tv) == FAIL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2171 return NOTDONE; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2172 clear_tv(tv); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2173 } |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2174 } |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2175 else if (dest_type == VAR_BLOB) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2176 { |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2177 long lidx = (long)tv_idx->vval.v_number; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2178 blob_T *blob = tv_dest->vval.v_blob; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2179 varnumber_T nr; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2180 int error = FALSE; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2181 int len; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2182 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2183 if (blob == NULL) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2184 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2185 emsg(_(e_blob_not_set)); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2186 return FAIL; |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2187 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2188 len = blob_len(blob); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2189 if (lidx < 0 && len + lidx >= 0) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2190 // negative index is relative to the end |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2191 lidx = len + lidx; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2192 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2193 // Can add one byte at the end. |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2194 if (lidx < 0 || lidx > len) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2195 { |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2196 semsg(_(e_blob_index_out_of_range_nr), lidx); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2197 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2198 } |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2199 if (value_check_lock(blob->bv_lock, (char_u *)"blob", FALSE)) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2200 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2201 nr = tv_get_number_chk(tv, &error); |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2202 if (error) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2203 return FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2204 blob_set_append(blob, lidx, nr); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2205 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2206 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2207 { |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2208 status = FAIL; |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
2209 semsg(_(e_cannot_index_str), vartype_name(dest_type)); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2210 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2211 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2212 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2213 clear_tv(tv_idx); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2214 clear_tv(tv_dest); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2215 ectx->ec_stack.ga_len -= 3; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2216 if (status == FAIL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2217 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2218 clear_tv(tv); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2219 return FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2220 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2221 return OK; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2222 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2223 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2224 /* |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2225 * Store a value in a list or blob range. |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2226 */ |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2227 static int |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2228 execute_storerange(isn_T *iptr, ectx_T *ectx) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2229 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2230 typval_T *tv; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2231 typval_T *tv_idx1 = STACK_TV_BOT(-3); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2232 typval_T *tv_idx2 = STACK_TV_BOT(-2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2233 typval_T *tv_dest = STACK_TV_BOT(-1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2234 int status = OK; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2235 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2236 // Stack contains: |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2237 // -4 value to be stored |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2238 // -3 first index or "none" |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2239 // -2 second index or "none" |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2240 // -1 destination list or blob |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2241 tv = STACK_TV_BOT(-4); |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2242 SOURCING_LNUM = iptr->isn_lnum; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2243 if (tv_dest->v_type == VAR_LIST) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2244 { |
28131
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2245 long n1; |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2246 long n2; |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2247 listitem_T *li1; |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2248 |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2249 n1 = (long)tv_get_number_chk(tv_idx1, NULL); |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2250 if (tv_idx2->v_type == VAR_SPECIAL |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2251 && tv_idx2->vval.v_number == VVAL_NONE) |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2252 n2 = list_len(tv_dest->vval.v_list) - 1; |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2253 else |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2254 n2 = (long)tv_get_number_chk(tv_idx2, NULL); |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2255 |
28273
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
2256 li1 = check_range_index_one(tv_dest->vval.v_list, &n1, TRUE, FALSE); |
28131
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2257 if (li1 == NULL) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2258 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2259 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2260 { |
28131
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2261 status = check_range_index_two(tv_dest->vval.v_list, |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2262 &n1, li1, &n2, FALSE); |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2263 if (status != FAIL) |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2264 status = list_assign_range( |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2265 tv_dest->vval.v_list, |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2266 tv->vval.v_list, |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2267 n1, |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2268 n2, |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2269 tv_idx2->v_type == VAR_SPECIAL, |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2270 (char_u *)"=", |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2271 (char_u *)"[unknown]"); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2272 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2273 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2274 else if (tv_dest->v_type == VAR_BLOB) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2275 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2276 varnumber_T n1; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2277 varnumber_T n2; |
28131
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2278 long bloblen; |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2279 |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2280 n1 = tv_get_number_chk(tv_idx1, NULL); |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2281 if (tv_idx2->v_type == VAR_SPECIAL |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2282 && tv_idx2->vval.v_number == VVAL_NONE) |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2283 n2 = blob_len(tv_dest->vval.v_blob) - 1; |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2284 else |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2285 n2 = tv_get_number_chk(tv_idx2, NULL); |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2286 bloblen = blob_len(tv_dest->vval.v_blob); |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2287 |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2288 if (check_blob_index(bloblen, n1, FALSE) == FAIL |
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2289 || check_blob_range(bloblen, n1, n2, FALSE) == FAIL) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2290 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2291 else |
28131
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28125
diff
changeset
|
2292 status = blob_set_range(tv_dest->vval.v_blob, n1, n2, tv); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2293 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2294 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2295 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2296 status = FAIL; |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2297 emsg(_(e_list_or_blob_required)); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2298 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2299 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2300 clear_tv(tv_idx1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2301 clear_tv(tv_idx2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2302 clear_tv(tv_dest); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2303 ectx->ec_stack.ga_len -= 4; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2304 clear_tv(tv); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2305 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2306 return status; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2307 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2308 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2309 /* |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2310 * Unlet item in list or dict variable. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2311 */ |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2312 static int |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2313 execute_unletindex(isn_T *iptr, ectx_T *ectx) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2314 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2315 typval_T *tv_idx = STACK_TV_BOT(-2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2316 typval_T *tv_dest = STACK_TV_BOT(-1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2317 int status = OK; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2318 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2319 // Stack contains: |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2320 // -2 index |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2321 // -1 dict or list |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2322 SOURCING_LNUM = iptr->isn_lnum; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2323 if (tv_dest->v_type == VAR_DICT) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2324 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2325 // unlet a dict item, index must be a string |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2326 if (tv_idx->v_type != VAR_STRING && tv_idx->v_type != VAR_NUMBER) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2327 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2328 semsg(_(e_expected_str_but_got_str), |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2329 vartype_name(VAR_STRING), |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2330 vartype_name(tv_idx->v_type)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2331 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2332 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2333 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2334 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2335 dict_T *d = tv_dest->vval.v_dict; |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2336 char_u *key; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2337 dictitem_T *di = NULL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2338 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2339 if (d != NULL && value_check_lock( |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2340 d->dv_lock, NULL, FALSE)) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2341 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2342 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2343 { |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2344 if (tv_idx->v_type == VAR_STRING) |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2345 { |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2346 key = tv_idx->vval.v_string; |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2347 if (key == NULL) |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2348 key = (char_u *)""; |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2349 } |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2350 else |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2351 { |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2352 key = tv_get_string(tv_idx); |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2353 } |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2354 if (d != NULL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2355 di = dict_find(d, key, (int)STRLEN(key)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2356 if (di == NULL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2357 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2358 // NULL dict is equivalent to empty dict |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2359 semsg(_(e_key_not_present_in_dictionary), |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2360 key); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2361 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2362 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2363 else if (var_check_fixed(di->di_flags, |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2364 NULL, FALSE) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2365 || var_check_ro(di->di_flags, |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2366 NULL, FALSE)) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2367 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2368 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2369 dictitem_remove(d, di); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2370 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2371 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2372 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2373 else if (tv_dest->v_type == VAR_LIST) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2374 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2375 // unlet a List item, index must be a number |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2376 if (check_for_number(tv_idx) == FAIL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2377 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2378 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2379 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2380 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2381 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2382 list_T *l = tv_dest->vval.v_list; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2383 long n = (long)tv_idx->vval.v_number; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2384 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2385 if (l != NULL && value_check_lock( |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2386 l->lv_lock, NULL, FALSE)) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2387 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2388 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2389 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2390 listitem_T *li = list_find(l, n); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2391 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2392 if (li == NULL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2393 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2394 semsg(_(e_list_index_out_of_range_nr), n); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2395 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2396 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2397 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2398 listitem_remove(l, li); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2399 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2400 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2401 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2402 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2403 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2404 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2405 semsg(_(e_cannot_index_str), |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2406 vartype_name(tv_dest->v_type)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2407 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2408 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2409 clear_tv(tv_idx); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2410 clear_tv(tv_dest); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2411 ectx->ec_stack.ga_len -= 2; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2412 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2413 return status; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2414 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2415 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2416 /* |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2417 * Unlet a range of items in a list variable. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2418 */ |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2419 static int |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2420 execute_unletrange(isn_T *iptr, ectx_T *ectx) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2421 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2422 // Stack contains: |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2423 // -3 index1 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2424 // -2 index2 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2425 // -1 dict or list |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2426 typval_T *tv_idx1 = STACK_TV_BOT(-3); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2427 typval_T *tv_idx2 = STACK_TV_BOT(-2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2428 typval_T *tv_dest = STACK_TV_BOT(-1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2429 int status = OK; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2430 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2431 if (tv_dest->v_type == VAR_LIST) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2432 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2433 // indexes must be a number |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2434 SOURCING_LNUM = iptr->isn_lnum; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2435 if (check_for_number(tv_idx1) == FAIL |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2436 || (tv_idx2->v_type != VAR_SPECIAL |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2437 && check_for_number(tv_idx2) == FAIL)) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2438 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2439 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2440 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2441 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2442 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2443 list_T *l = tv_dest->vval.v_list; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2444 long n1 = (long)tv_idx1->vval.v_number; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2445 long n2 = tv_idx2->v_type == VAR_SPECIAL |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2446 ? 0 : (long)tv_idx2->vval.v_number; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2447 listitem_T *li; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2448 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2449 li = list_find_index(l, &n1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2450 if (li == NULL) |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2451 { |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2452 semsg(_(e_list_index_out_of_range_nr), |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2453 (long)tv_idx1->vval.v_number); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2454 status = FAIL; |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2455 } |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2456 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2457 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2458 if (n1 < 0) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2459 n1 = list_idx_of_item(l, li); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2460 if (n2 < 0) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2461 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2462 listitem_T *li2 = list_find(l, n2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2463 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2464 if (li2 == NULL) |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2465 { |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2466 semsg(_(e_list_index_out_of_range_nr), n2); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2467 status = FAIL; |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2468 } |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2469 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2470 n2 = list_idx_of_item(l, li2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2471 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2472 if (status != FAIL |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2473 && tv_idx2->v_type != VAR_SPECIAL |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2474 && n2 < n1) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2475 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2476 semsg(_(e_list_index_out_of_range_nr), n2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2477 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2478 } |
28152
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2479 if (status != FAIL) |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2480 list_unlet_range(l, li, n1, |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2481 tv_idx2->v_type != VAR_SPECIAL, n2); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2482 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2483 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2484 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2485 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2486 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2487 status = FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2488 SOURCING_LNUM = iptr->isn_lnum; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2489 semsg(_(e_cannot_index_str), |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2490 vartype_name(tv_dest->v_type)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2491 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2492 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2493 clear_tv(tv_idx1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2494 clear_tv(tv_idx2); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2495 clear_tv(tv_dest); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2496 ectx->ec_stack.ga_len -= 3; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2497 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2498 return status; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2499 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2500 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2501 /* |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2502 * Top of a for loop. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2503 */ |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2504 static int |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2505 execute_for(isn_T *iptr, ectx_T *ectx) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2506 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2507 typval_T *tv; |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2508 int jump = FALSE; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2509 typval_T *ltv = STACK_TV_BOT(-1); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2510 typval_T *idxtv = |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2511 STACK_TV_VAR(iptr->isn_arg.forloop.for_loop_idx); |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2512 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2513 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2514 return FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2515 if (ltv->v_type == VAR_LIST) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2516 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2517 list_T *list = ltv->vval.v_list; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2518 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2519 // push the next item from the list |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2520 ++idxtv->vval.v_number; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2521 if (list == NULL |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2522 || idxtv->vval.v_number >= list->lv_len) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2523 { |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2524 jump = TRUE; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2525 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2526 else if (list->lv_first == &range_list_item) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2527 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2528 // non-materialized range() list |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2529 tv = STACK_TV_BOT(0); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2530 tv->v_type = VAR_NUMBER; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2531 tv->v_lock = 0; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2532 tv->vval.v_number = list_find_nr( |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2533 list, idxtv->vval.v_number, NULL); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2534 ++ectx->ec_stack.ga_len; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2535 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2536 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2537 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2538 listitem_T *li = list_find(list, |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2539 idxtv->vval.v_number); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2540 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2541 copy_tv(&li->li_tv, STACK_TV_BOT(0)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2542 ++ectx->ec_stack.ga_len; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2543 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2544 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2545 else if (ltv->v_type == VAR_STRING) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2546 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2547 char_u *str = ltv->vval.v_string; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2548 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2549 // The index is for the last byte of the previous |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2550 // character. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2551 ++idxtv->vval.v_number; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2552 if (str == NULL || str[idxtv->vval.v_number] == NUL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2553 { |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2554 jump = TRUE; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2555 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2556 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2557 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2558 int clen = mb_ptr2len(str + idxtv->vval.v_number); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2559 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2560 // Push the next character from the string. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2561 tv = STACK_TV_BOT(0); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2562 tv->v_type = VAR_STRING; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2563 tv->vval.v_string = vim_strnsave( |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2564 str + idxtv->vval.v_number, clen); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2565 ++ectx->ec_stack.ga_len; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2566 idxtv->vval.v_number += clen - 1; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2567 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2568 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2569 else if (ltv->v_type == VAR_BLOB) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2570 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2571 blob_T *blob = ltv->vval.v_blob; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2572 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2573 // When we get here the first time make a copy of the |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2574 // blob, so that the iteration still works when it is |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2575 // changed. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2576 if (idxtv->vval.v_number == -1 && blob != NULL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2577 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2578 blob_copy(blob, ltv); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2579 blob_unref(blob); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2580 blob = ltv->vval.v_blob; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2581 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2582 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2583 // The index is for the previous byte. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2584 ++idxtv->vval.v_number; |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2585 if (blob == NULL || idxtv->vval.v_number >= blob_len(blob)) |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2586 { |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2587 jump = TRUE; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2588 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2589 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2590 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2591 // Push the next byte from the blob. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2592 tv = STACK_TV_BOT(0); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2593 tv->v_type = VAR_NUMBER; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2594 tv->vval.v_number = blob_get(blob, |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2595 idxtv->vval.v_number); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2596 ++ectx->ec_stack.ga_len; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2597 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2598 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2599 else |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2600 { |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2601 semsg(_(e_for_loop_on_str_not_supported), |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2602 vartype_name(ltv->v_type)); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2603 return FAIL; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2604 } |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2605 |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2606 if (jump) |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2607 { |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2608 // past the end of the list/string/blob, jump to "endfor" |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2609 ectx->ec_iidx = iptr->isn_arg.forloop.for_end; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2610 may_restore_cmdmod(&ectx->ec_funclocal); |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2611 } |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2612 else |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2613 { |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2614 // Store the current number of funcrefs, this may be used in |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2615 // ISN_LOOPEND. The variable index is always one more than the loop |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2616 // variable index. |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2617 tv = STACK_TV_VAR(iptr->isn_arg.forloop.for_loop_idx + 1); |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2618 tv->vval.v_number = ectx->ec_funcrefs.ga_len; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2619 } |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2620 |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2621 return OK; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2622 } |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2623 |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2624 /* |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2625 * Code for handling variables declared inside a loop and used in a closure. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2626 * This is very similar to what is done with funcstack_T. The difference is |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2627 * that the funcstack_T has the scope of a function, while a loopvars_T has the |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2628 * scope of the block inside a loop and each loop may have its own. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2629 */ |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2630 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2631 // Double linked list of loopvars_T in use. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2632 static loopvars_T *first_loopvars = NULL; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2633 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2634 static void |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2635 add_loopvars_to_list(loopvars_T *loopvars) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2636 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2637 // Link in list of loopvarss. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2638 if (first_loopvars != NULL) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2639 first_loopvars->lvs_prev = loopvars; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2640 loopvars->lvs_next = first_loopvars; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2641 loopvars->lvs_prev = NULL; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2642 first_loopvars = loopvars; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2643 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2644 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2645 static void |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2646 remove_loopvars_from_list(loopvars_T *loopvars) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2647 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2648 if (loopvars->lvs_prev == NULL) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2649 first_loopvars = loopvars->lvs_next; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2650 else |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2651 loopvars->lvs_prev->lvs_next = loopvars->lvs_next; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2652 if (loopvars->lvs_next != NULL) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2653 loopvars->lvs_next->lvs_prev = loopvars->lvs_prev; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2654 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2655 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2656 /* |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2657 * End of a for or while loop: Handle any variables used by a closure. |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2658 */ |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2659 static int |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2660 execute_endloop(isn_T *iptr, ectx_T *ectx) |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2661 { |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2662 endloop_T *endloop = &iptr->isn_arg.endloop; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2663 typval_T *tv_refcount = STACK_TV_VAR(endloop->end_funcref_idx); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2664 int prev_closure_count = tv_refcount->vval.v_number; |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2665 int depth = endloop->end_depth; |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2666 garray_T *gap = &ectx->ec_funcrefs; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2667 int closure_in_use = FALSE; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2668 loopvars_T *loopvars; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2669 typval_T *stack; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2670 int idx; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2671 |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2672 // Check if any created closure is still being referenced and loopvars have |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2673 // not been saved yet for the current depth. |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2674 for (idx = prev_closure_count; idx < gap->ga_len; ++idx) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2675 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2676 partial_T *pt = ((partial_T **)gap->ga_data)[idx]; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2677 |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2678 if (pt->pt_refcount > 1 && pt->pt_loopvars[depth] == NULL) |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2679 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2680 int refcount = pt->pt_refcount; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2681 int i; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2682 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2683 // A Reference in a variable inside the loop doesn't count, it gets |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2684 // unreferenced at the end of the loop. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2685 for (i = 0; i < endloop->end_var_count; ++i) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2686 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2687 typval_T *stv = STACK_TV_VAR(endloop->end_var_idx + i); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2688 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2689 if (stv->v_type == VAR_PARTIAL && pt == stv->vval.v_partial) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2690 --refcount; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2691 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2692 if (refcount > 1) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2693 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2694 closure_in_use = TRUE; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2695 break; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2696 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2697 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2698 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2699 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2700 // If no function reference were created since the start of the loop block |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2701 // or it is no longer referenced there is nothing to do. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2702 if (!closure_in_use) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2703 return OK; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2704 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2705 // A closure is using variables declared inside the loop. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2706 // Move them to the called function. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2707 loopvars = ALLOC_CLEAR_ONE(loopvars_T); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2708 if (loopvars == NULL) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2709 return FAIL; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2710 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2711 loopvars->lvs_ga.ga_len = endloop->end_var_count; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2712 stack = ALLOC_CLEAR_MULT(typval_T, loopvars->lvs_ga.ga_len); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2713 loopvars->lvs_ga.ga_data = stack; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2714 if (stack == NULL) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2715 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2716 vim_free(loopvars); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2717 return FAIL; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2718 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2719 add_loopvars_to_list(loopvars); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2720 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2721 // Move the variable values. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2722 for (idx = 0; idx < endloop->end_var_count; ++idx) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2723 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2724 typval_T *tv = STACK_TV_VAR(endloop->end_var_idx + idx); |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2725 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2726 *(stack + idx) = *tv; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2727 tv->v_type = VAR_UNKNOWN; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2728 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2729 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2730 for (idx = prev_closure_count; idx < gap->ga_len; ++idx) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2731 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2732 partial_T *pt = ((partial_T **)gap->ga_data)[idx]; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2733 |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2734 if (pt->pt_refcount > 1 && pt->pt_loopvars[depth] == NULL) |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2735 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2736 ++loopvars->lvs_refcount; |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2737 pt->pt_loopvars[depth] = loopvars; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2738 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2739 pt->pt_outer.out_loop[depth].stack = &loopvars->lvs_ga; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2740 pt->pt_outer.out_loop[depth].var_idx -= |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2741 ectx->ec_frame_idx + STACK_FRAME_SIZE + endloop->end_var_idx; |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2742 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2743 } |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
2744 |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2745 return OK; |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2746 } |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2747 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2748 /* |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2749 * Called when a partial is freed or its reference count goes down to one. The |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2750 * loopvars may be the only reference to the partials in the local variables. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2751 * Go over all of them, the funcref and can be freed if all partials |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2752 * referencing the loopvars have a reference count of one. |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2753 * Return TRUE if it was freed. |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2754 */ |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2755 int |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2756 loopvars_check_refcount(loopvars_T *loopvars) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2757 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2758 int i; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2759 garray_T *gap = &loopvars->lvs_ga; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2760 int done = 0; |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2761 typval_T *stack = gap->ga_data; |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2762 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2763 if (loopvars->lvs_refcount > loopvars->lvs_min_refcount) |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2764 return FALSE; |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2765 for (i = 0; i < gap->ga_len; ++i) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2766 { |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2767 typval_T *tv = ((typval_T *)gap->ga_data) + i; |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2768 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2769 if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial != NULL |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2770 && tv->vval.v_partial->pt_refcount == 1) |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2771 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2772 int depth; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2773 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2774 for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2775 if (tv->vval.v_partial->pt_loopvars[depth] == loopvars) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2776 ++done; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2777 } |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2778 } |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2779 if (done != loopvars->lvs_min_refcount) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2780 return FALSE; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2781 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2782 // All partials referencing the loopvars have a reference count of |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2783 // one, thus the loopvars is no longer of use. |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2784 stack = gap->ga_data; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2785 for (i = 0; i < gap->ga_len; ++i) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2786 clear_tv(stack + i); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2787 vim_free(stack); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2788 remove_loopvars_from_list(loopvars); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2789 vim_free(loopvars); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
2790 return TRUE; |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2791 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2792 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2793 /* |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2794 * For garbage collecting: set references in all variables referenced by |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2795 * all loopvars. |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2796 */ |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2797 int |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2798 set_ref_in_loopvars(int copyID) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2799 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2800 loopvars_T *loopvars; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2801 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2802 for (loopvars = first_loopvars; loopvars != NULL; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2803 loopvars = loopvars->lvs_next) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2804 { |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2805 typval_T *stack = loopvars->lvs_ga.ga_data; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2806 int i; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2807 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2808 for (i = 0; i < loopvars->lvs_ga.ga_len; ++i) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2809 if (set_ref_in_item(stack + i, copyID, NULL, NULL)) |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2810 return TRUE; // abort |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2811 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2812 return FALSE; |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2813 } |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2814 |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
2815 /* |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2816 * Load instruction for w:/b:/g:/t: variable. |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2817 * "isn_type" is used instead of "iptr->isn_type". |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2818 */ |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2819 static int |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2820 load_namespace_var(ectx_T *ectx, isntype_T isn_type, isn_T *iptr) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2821 { |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2822 dictitem_T *di = NULL; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2823 hashtab_T *ht = NULL; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2824 char namespace; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2825 |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2826 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2827 return NOTDONE; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2828 switch (isn_type) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2829 { |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2830 case ISN_LOADG: |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2831 ht = get_globvar_ht(); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2832 namespace = 'g'; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2833 break; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2834 case ISN_LOADB: |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2835 ht = &curbuf->b_vars->dv_hashtab; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2836 namespace = 'b'; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2837 break; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2838 case ISN_LOADW: |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2839 ht = &curwin->w_vars->dv_hashtab; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2840 namespace = 'w'; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2841 break; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2842 case ISN_LOADT: |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2843 ht = &curtab->tp_vars->dv_hashtab; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2844 namespace = 't'; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2845 break; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2846 default: // Cannot reach here |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2847 return NOTDONE; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2848 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2849 di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2850 |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2851 if (di == NULL) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2852 { |
27841
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2853 if (isn_type == ISN_LOADG) |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2854 { |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2855 ufunc_T *ufunc = find_func(iptr->isn_arg.string, TRUE); |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2856 |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2857 // g:Something could be a function |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2858 if (ufunc != NULL) |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2859 { |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2860 typval_T *tv = STACK_TV_BOT(0); |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2861 |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2862 ++ectx->ec_stack.ga_len; |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2863 tv->v_type = VAR_FUNC; |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2864 tv->vval.v_string = alloc(STRLEN(iptr->isn_arg.string) + 3); |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2865 if (tv->vval.v_string == NULL) |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2866 return FAIL; |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2867 STRCPY(tv->vval.v_string, "g:"); |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2868 STRCPY(tv->vval.v_string + 2, iptr->isn_arg.string); |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2869 return OK; |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2870 } |
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2871 } |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2872 SOURCING_LNUM = iptr->isn_lnum; |
27841
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2873 if (vim_strchr(iptr->isn_arg.string, AUTOLOAD_CHAR) != NULL) |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2874 // no check if the item exists in the script but |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2875 // isn't exported, it is too complicated |
27841
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2876 semsg(_(e_item_not_found_in_script_str), iptr->isn_arg.string); |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2877 else |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2878 semsg(_(e_undefined_variable_char_str), |
27841
5ce69c07a106
patch 8.2.4446: Vim9: cannot refer to a global function like a local one
Bram Moolenaar <Bram@vim.org>
parents:
27774
diff
changeset
|
2879 namespace, iptr->isn_arg.string); |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2880 return FAIL; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2881 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2882 else |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2883 { |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2884 copy_tv(&di->di_tv, STACK_TV_BOT(0)); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2885 ++ectx->ec_stack.ga_len; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2886 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2887 return OK; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2888 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2889 |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
2890 /* |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2891 * Execute instructions in execution context "ectx". |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2892 * Return OK or FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2893 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2894 static int |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2895 exec_instructions(ectx_T *ectx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2896 { |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2897 int ret = FAIL; |
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2898 int save_trylevel_at_start = ectx->ec_trylevel_at_start; |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
2899 int dict_stack_len_at_start = dict_stack.ga_len; |
23917
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23839
diff
changeset
|
2900 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
2901 // Start execution at the first instruction. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2902 ectx->ec_iidx = 0; |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
2903 |
24637
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24614
diff
changeset
|
2904 // Only catch exceptions in this instruction list. |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24614
diff
changeset
|
2905 ectx->ec_trylevel_at_start = trylevel; |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24614
diff
changeset
|
2906 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2907 for (;;) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2908 { |
25324
af0fd37ae687
patch 8.2.3199: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
2909 static int breakcheck_count = 0; // using "static" makes it faster |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2910 isn_T *iptr; |
25324
af0fd37ae687
patch 8.2.3199: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
2911 typval_T *tv; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2912 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
2913 if (unlikely(++breakcheck_count >= 100)) |
20409
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
2914 { |
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
2915 line_breakcheck(); |
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
2916 breakcheck_count = 0; |
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
2917 } |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
2918 if (unlikely(got_int)) |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2919 { |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2920 // Turn CTRL-C into an exception. |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2921 got_int = FALSE; |
19736
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19726
diff
changeset
|
2922 if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2923 goto theend; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2924 did_throw = TRUE; |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2925 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2926 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
2927 if (unlikely(did_emsg && msg_list != NULL && *msg_list != NULL)) |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2928 { |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2929 // Turn an error message into an exception. |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2930 did_emsg = FALSE; |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2931 if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2932 goto theend; |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2933 did_throw = TRUE; |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2934 *msg_list = NULL; |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2935 } |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
2936 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
2937 if (unlikely(did_throw)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2938 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2939 garray_T *trystack = &ectx->ec_trystack; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
2940 trycmd_T *trycmd = NULL; |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2941 int index = trystack->ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2942 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2943 // An exception jumps to the first catch, finally, or returns from |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2944 // the current function. |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2945 while (index > 0) |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2946 { |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2947 trycmd = ((trycmd_T *)trystack->ga_data) + index - 1; |
25082
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2948 if (!trycmd->tcd_in_catch || trycmd->tcd_finally_idx != 0) |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2949 break; |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2950 // In the catch and finally block of this try we have to go up |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2951 // one level. |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2952 --index; |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2953 trycmd = NULL; |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2954 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2955 if (trycmd != NULL && trycmd->tcd_frame_idx == ectx->ec_frame_idx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2956 { |
25082
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2957 if (trycmd->tcd_in_catch) |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2958 { |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2959 // exception inside ":catch", jump to ":finally" once |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2960 ectx->ec_iidx = trycmd->tcd_finally_idx; |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2961 trycmd->tcd_finally_idx = 0; |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2962 } |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2963 else |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2964 // jump to first ":catch" |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
2965 ectx->ec_iidx = trycmd->tcd_catch_idx; |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2966 trycmd->tcd_in_catch = TRUE; |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2967 did_throw = FALSE; // don't come back here until :endtry |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
2968 trycmd->tcd_did_throw = TRUE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2969 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2970 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2971 { |
21787
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2972 // Not inside try or need to return from current functions. |
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2973 // Push a dummy return value. |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2974 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2975 goto theend; |
21787
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2976 tv = STACK_TV_BOT(0); |
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2977 tv->v_type = VAR_NUMBER; |
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2978 tv->vval.v_number = 0; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2979 ++ectx->ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2980 if (ectx->ec_frame_idx == ectx->ec_initial_frame_idx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2981 { |
21787
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2982 // At the toplevel we are done. |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19411
diff
changeset
|
2983 need_rethrow = TRUE; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2984 if (handle_closure_in_use(ectx, FALSE) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2985 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2986 goto done; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2987 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2988 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2989 if (func_return(ectx) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2990 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2991 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2992 continue; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2993 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2994 |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2995 /* |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2996 * Big switch on the instruction. Most compilers will be turning this |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2997 * into an efficient lookup table, since the "case" values are an enum |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2998 * with sequential numbers. It may look ugly, but it should be the |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
2999 * most efficient way. |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3000 */ |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3001 iptr = &ectx->ec_instr[ectx->ec_iidx++]; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3002 switch (iptr->isn_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3003 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3004 // execute Ex command line |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3005 case ISN_EXEC: |
25605
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3006 if (exec_command(iptr) == FAIL) |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3007 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3008 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3009 |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3010 // execute Ex command line split at NL characters. |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3011 case ISN_EXEC_SPLIT: |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3012 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3013 source_cookie_T cookie; |
24830
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3014 char_u *line; |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3015 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3016 SOURCING_LNUM = iptr->isn_lnum; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3017 CLEAR_FIELD(cookie); |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3018 cookie.sourcing_lnum = iptr->isn_lnum - 1; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3019 cookie.nextline = iptr->isn_arg.string; |
24830
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3020 line = get_split_sourceline(0, &cookie, 0, 0); |
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3021 if (do_cmdline(line, |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3022 get_split_sourceline, &cookie, |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3023 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3024 == FAIL |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3025 || did_emsg) |
24830
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3026 { |
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3027 vim_free(line); |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3028 goto on_error; |
24830
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3029 } |
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
3030 vim_free(line); |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3031 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3032 break; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
3033 |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3034 // execute Ex command line that is only a range |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3035 case ISN_EXECRANGE: |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3036 { |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3037 exarg_T ea; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3038 char *error = NULL; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3039 |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3040 CLEAR_FIELD(ea); |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3041 ea.cmdidx = CMD_SIZE; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3042 ea.addr_type = ADDR_LINES; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3043 ea.cmd = iptr->isn_arg.string; |
27768
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
3044 SOURCING_LNUM = iptr->isn_lnum; |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3045 parse_cmd_address(&ea, &error, FALSE); |
26406
fcc57227e99b
patch 8.2.3734: Vim9: crash when no pattern match found
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
3046 if (ea.cmd == NULL) |
fcc57227e99b
patch 8.2.3734: Vim9: crash when no pattern match found
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
3047 goto on_error; |
27768
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
3048 // error is always NULL when using ADDR_LINES |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
3049 error = ex_range_without_command(&ea); |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3050 if (error != NULL) |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3051 { |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3052 emsg(error); |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3053 goto on_error; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3054 } |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3055 } |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3056 break; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
3057 |
24645
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3058 // Evaluate an expression with legacy syntax, push it onto the |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3059 // stack. |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3060 case ISN_LEGACY_EVAL: |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3061 { |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3062 char_u *arg = iptr->isn_arg.string; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3063 int res; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3064 int save_flags = cmdmod.cmod_flags; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3065 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3066 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3067 goto theend; |
24645
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3068 tv = STACK_TV_BOT(0); |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3069 init_tv(tv); |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3070 cmdmod.cmod_flags |= CMOD_LEGACY; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3071 res = eval0(arg, tv, NULL, &EVALARG_EVALUATE); |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3072 cmdmod.cmod_flags = save_flags; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3073 if (res == FAIL) |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3074 goto on_error; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3075 ++ectx->ec_stack.ga_len; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3076 } |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3077 break; |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
3078 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3079 // push typeval VAR_INSTR with instructions to be executed |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3080 case ISN_INSTR: |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3081 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3082 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3083 goto theend; |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3084 tv = STACK_TV_BOT(0); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3085 tv->vval.v_instr = ALLOC_ONE(instr_T); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3086 if (tv->vval.v_instr == NULL) |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3087 goto on_error; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3088 ++ectx->ec_stack.ga_len; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3089 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3090 tv->v_type = VAR_INSTR; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3091 tv->vval.v_instr->instr_ectx = ectx; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3092 tv->vval.v_instr->instr_instr = iptr->isn_arg.instr; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3093 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3094 break; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3095 |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3096 case ISN_SOURCE: |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3097 { |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
3098 int notused; |
28459
52ef65c0637f
patch 8.2.4754: using cached values after unsetting some environment variables
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
3099 |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
3100 SOURCING_LNUM = iptr->isn_lnum; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
3101 if (may_load_script((int)iptr->isn_arg.number, ¬used) |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3102 == FAIL) |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
3103 goto on_error; |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3104 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3105 break; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3106 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3107 // execute :substitute with an expression |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3108 case ISN_SUBSTITUTE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3109 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3110 subs_T *subs = &iptr->isn_arg.subs; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3111 source_cookie_T cookie; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3112 struct subs_expr_S *save_instr = substitute_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3113 struct subs_expr_S subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3114 int res; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3115 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3116 subs_instr.subs_ectx = ectx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3117 subs_instr.subs_instr = subs->subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3118 subs_instr.subs_status = OK; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3119 substitute_instr = &subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3120 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3121 SOURCING_LNUM = iptr->isn_lnum; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3122 // This is very much like ISN_EXEC |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3123 CLEAR_FIELD(cookie); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3124 cookie.sourcing_lnum = iptr->isn_lnum - 1; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3125 res = do_cmdline(subs->subs_cmd, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3126 getsourceline, &cookie, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3127 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3128 substitute_instr = save_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3129 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3130 if (res == FAIL || did_emsg |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3131 || subs_instr.subs_status == FAIL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3132 goto on_error; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3133 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3134 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3135 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3136 case ISN_FINISH: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3137 goto done; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3138 |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3139 case ISN_REDIRSTART: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3140 // create a dummy entry for var_redir_str() |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3141 if (alloc_redir_lval() == FAIL) |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3142 goto on_error; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3143 |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3144 // The output is stored in growarray "redir_ga" until |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3145 // redirection ends. |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3146 init_redir_ga(); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3147 redir_vname = 1; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3148 break; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3149 |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3150 case ISN_REDIREND: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3151 { |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3152 char_u *res = get_clear_redir_ga(); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3153 |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3154 // End redirection, put redirected text on the stack. |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3155 clear_redir_lval(); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3156 redir_vname = 0; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3157 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3158 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3159 { |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3160 vim_free(res); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3161 goto theend; |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3162 } |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3163 tv = STACK_TV_BOT(0); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3164 tv->v_type = VAR_STRING; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3165 tv->vval.v_string = res; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3166 ++ectx->ec_stack.ga_len; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3167 } |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3168 break; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
3169 |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3170 case ISN_CEXPR_AUCMD: |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
3171 #ifdef FEAT_QUICKFIX |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
3172 force_abort = TRUE; |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3173 if (trigger_cexpr_autocmd(iptr->isn_arg.number) == FAIL) |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3174 goto on_error; |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
3175 force_abort = FALSE; |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
3176 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3177 break; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3178 |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3179 case ISN_CEXPR_CORE: |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
3180 #ifdef FEAT_QUICKFIX |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3181 { |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3182 exarg_T ea; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3183 int res; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3184 |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3185 CLEAR_FIELD(ea); |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3186 ea.cmdidx = iptr->isn_arg.cexpr.cexpr_ref->cer_cmdidx; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3187 ea.forceit = iptr->isn_arg.cexpr.cexpr_ref->cer_forceit; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3188 ea.cmdlinep = &iptr->isn_arg.cexpr.cexpr_ref->cer_cmdline; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3189 --ectx->ec_stack.ga_len; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3190 tv = STACK_TV_BOT(0); |
29429
aeba55253de4
patch 9.0.0056: wrong line number reported when :cexpr fails in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29322
diff
changeset
|
3191 SOURCING_LNUM = iptr->isn_lnum; |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3192 res = cexpr_core(&ea, tv); |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3193 clear_tv(tv); |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3194 if (res == FAIL) |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3195 goto on_error; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3196 } |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
3197 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3198 break; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
3199 |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3200 // execute Ex command from pieces on the stack |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3201 case ISN_EXECCONCAT: |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3202 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3203 int count = iptr->isn_arg.number; |
20225
eaaee0dfa435
patch 8.2.0668: compiler warning for int/size_t usage
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
3204 size_t len = 0; |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3205 int pass; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3206 int i; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3207 char_u *cmd = NULL; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3208 char_u *str; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3209 |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3210 for (pass = 1; pass <= 2; ++pass) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3211 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3212 for (i = 0; i < count; ++i) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3213 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3214 tv = STACK_TV_BOT(i - count); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3215 str = tv->vval.v_string; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3216 if (str != NULL && *str != NUL) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3217 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3218 if (pass == 2) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3219 STRCPY(cmd + len, str); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3220 len += STRLEN(str); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3221 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3222 if (pass == 2) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3223 clear_tv(tv); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3224 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3225 if (pass == 1) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3226 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3227 cmd = alloc(len + 1); |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3228 if (unlikely(cmd == NULL)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3229 goto theend; |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3230 len = 0; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3231 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3232 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3233 |
20172
1d84eaed0ec8
patch 8.2.0641: Vim9: not expanded in :hardcopy and syn-include
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
3234 SOURCING_LNUM = iptr->isn_lnum; |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3235 do_cmdline_cmd(cmd); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3236 vim_free(cmd); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3237 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3238 break; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
3239 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3240 // execute :echo {string} ... |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3241 case ISN_ECHO: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3242 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3243 int count = iptr->isn_arg.echo.echo_count; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3244 int atstart = TRUE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3245 int needclr = TRUE; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3246 int idx; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3247 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3248 for (idx = 0; idx < count; ++idx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3249 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3250 tv = STACK_TV_BOT(idx - count); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3251 echo_one(tv, iptr->isn_arg.echo.echo_with_white, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3252 &atstart, &needclr); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3253 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3254 } |
19463
798fce18d049
patch 8.2.0289: Vim9: :echo did not clear the rest of the line
Bram Moolenaar <Bram@vim.org>
parents:
19459
diff
changeset
|
3255 if (needclr) |
798fce18d049
patch 8.2.0289: Vim9: :echo did not clear the rest of the line
Bram Moolenaar <Bram@vim.org>
parents:
19459
diff
changeset
|
3256 msg_clr_eos(); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3257 ectx->ec_stack.ga_len -= count; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3258 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3259 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3260 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3261 // :execute {string} ... |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3262 // :echomsg {string} ... |
30025
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3263 // :echowindow {string} ... |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3264 // :echoconsole {string} ... |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3265 // :echoerr {string} ... |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3266 case ISN_EXECUTE: |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3267 case ISN_ECHOMSG: |
30025
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3268 case ISN_ECHOWINDOW: |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3269 case ISN_ECHOCONSOLE: |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3270 case ISN_ECHOERR: |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3271 { |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3272 int count = iptr->isn_arg.number; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3273 garray_T ga; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3274 char_u buf[NUMBUFLEN]; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3275 char_u *p; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3276 int len; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3277 int failed = FALSE; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3278 int idx; |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3279 |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3280 ga_init2(&ga, 1, 80); |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3281 for (idx = 0; idx < count; ++idx) |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3282 { |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3283 tv = STACK_TV_BOT(idx - count); |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3284 if (iptr->isn_type == ISN_EXECUTE) |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3285 { |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3286 if (tv->v_type == VAR_CHANNEL |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3287 || tv->v_type == VAR_JOB) |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3288 { |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3289 SOURCING_LNUM = iptr->isn_lnum; |
24614
07b3d21a8b4b
patch 8.2.2846: Vim9: "echo Func()" does not give an error for using void
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
3290 semsg(_(e_using_invalid_value_as_string_str), |
07b3d21a8b4b
patch 8.2.2846: Vim9: "echo Func()" does not give an error for using void
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
3291 vartype_name(tv->v_type)); |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3292 break; |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3293 } |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3294 else |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3295 p = tv_get_string_buf(tv, buf); |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3296 } |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3297 else |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3298 p = tv_stringify(tv, buf); |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3299 |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3300 len = (int)STRLEN(p); |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3301 if (GA_GROW_FAILS(&ga, len + 2)) |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3302 failed = TRUE; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3303 else |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3304 { |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3305 if (ga.ga_len > 0) |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3306 ((char_u *)(ga.ga_data))[ga.ga_len++] = ' '; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3307 STRCPY((char_u *)(ga.ga_data) + ga.ga_len, p); |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3308 ga.ga_len += len; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3309 } |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3310 clear_tv(tv); |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3311 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3312 ectx->ec_stack.ga_len -= count; |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3313 if (failed) |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3314 { |
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3315 ga_clear(&ga); |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3316 goto on_error; |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3317 } |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3318 |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
3319 if (ga.ga_data != NULL) |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3320 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3321 if (iptr->isn_type == ISN_EXECUTE) |
21933
5edd776d886d
patch 8.2.1516: Vim9: error for :exe has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
3322 { |
5edd776d886d
patch 8.2.1516: Vim9: error for :exe has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
3323 SOURCING_LNUM = iptr->isn_lnum; |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3324 do_cmdline_cmd((char_u *)ga.ga_data); |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3325 if (did_emsg) |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3326 { |
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3327 ga_clear(&ga); |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3328 goto on_error; |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3329 } |
21933
5edd776d886d
patch 8.2.1516: Vim9: error for :exe has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
3330 } |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3331 else |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3332 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3333 msg_sb_eol(); |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3334 if (iptr->isn_type == ISN_ECHOMSG) |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3335 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3336 msg_attr(ga.ga_data, echo_attr); |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3337 out_flush(); |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3338 } |
30025
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3339 #ifdef HAS_MESSAGE_WINDOW |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3340 else if (iptr->isn_type == ISN_ECHOWINDOW) |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3341 { |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3342 start_echowindow(); |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3343 msg_attr(ga.ga_data, echo_attr); |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3344 end_echowindow(); |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3345 } |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
3346 #endif |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3347 else if (iptr->isn_type == ISN_ECHOCONSOLE) |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3348 { |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3349 ui_write(ga.ga_data, (int)STRLEN(ga.ga_data), |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3350 TRUE); |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3351 ui_write((char_u *)"\r\n", 2, TRUE); |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
3352 } |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3353 else |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3354 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3355 SOURCING_LNUM = iptr->isn_lnum; |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3356 emsg(ga.ga_data); |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3357 } |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3358 } |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
3359 } |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3360 ga_clear(&ga); |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3361 } |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3362 break; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
3363 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3364 // load local variable or argument |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3365 case ISN_LOAD: |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3366 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3367 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3368 copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3369 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3370 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3372 // load v: variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3373 case ISN_LOADV: |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3374 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3375 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3376 copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3377 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3378 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3379 |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3380 // load s: variable in Vim9 script |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3381 case ISN_LOADSCRIPT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3382 { |
23330
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23295
diff
changeset
|
3383 scriptref_T *sref = iptr->isn_arg.script.scriptref; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3384 svar_T *sv; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3385 |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
3386 sv = get_script_svar(sref, ectx->ec_dfunc_idx); |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
3387 if (sv == NULL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3388 goto theend; |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
3389 allocate_if_null(sv); |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3390 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3391 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3392 copy_tv(sv->sv_tv, STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3393 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3394 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3395 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3396 |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3397 // load s: variable in old script or autoload import |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3398 case ISN_LOADS: |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3399 case ISN_LOADEXPORT: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3400 { |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3401 int sid = iptr->isn_arg.loadstore.ls_sid; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3402 hashtab_T *ht = &SCRIPT_VARS(sid); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3403 char_u *name = iptr->isn_arg.loadstore.ls_name; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3404 dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE); |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
3405 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3406 if (di == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3407 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
3408 SOURCING_LNUM = iptr->isn_lnum; |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
3409 semsg(_(e_undefined_variable_str), name); |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
3410 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3411 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3412 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3413 { |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3414 if (iptr->isn_type == ISN_LOADEXPORT) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3415 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3416 int idx = get_script_item_idx(sid, name, 0, |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3417 NULL, NULL); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3418 svar_T *sv; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3419 |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3420 if (idx >= 0) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3421 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3422 sv = ((svar_T *)SCRIPT_ITEM(sid) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3423 ->sn_var_vals.ga_data) + idx; |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3424 if ((sv->sv_flags & SVFLAG_EXPORTED) == 0) |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3425 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3426 SOURCING_LNUM = iptr->isn_lnum; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3427 semsg(_(e_item_not_exported_in_script_str), |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3428 name); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3429 goto on_error; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3430 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3431 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3432 } |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3433 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3434 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3435 copy_tv(&di->di_tv, STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3436 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3437 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3438 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3439 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3440 |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3441 // load g:/b:/w:/t: variable |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3442 case ISN_LOADG: |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3443 case ISN_LOADB: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3444 case ISN_LOADW: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3445 case ISN_LOADT: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3446 { |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3447 int res = load_namespace_var(ectx, iptr->isn_type, iptr); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3448 |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3449 if (res == NOTDONE) |
27205
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
3450 goto theend; |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3451 if (res == FAIL) |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
3452 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3453 } |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3454 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3455 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3456 |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3457 // load autoload variable |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3458 case ISN_LOADAUTO: |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3459 { |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3460 char_u *name = iptr->isn_arg.string; |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3461 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3462 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3463 goto theend; |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3464 SOURCING_LNUM = iptr->isn_lnum; |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26891
diff
changeset
|
3465 if (eval_variable(name, (int)STRLEN(name), 0, |
24112
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
3466 STACK_TV_BOT(0), NULL, EVAL_VAR_VERBOSE) == FAIL) |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3467 goto on_error; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3468 ++ectx->ec_stack.ga_len; |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3469 } |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3470 break; |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3471 |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3472 // load g:/b:/w:/t: namespace |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3473 case ISN_LOADGDICT: |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3474 case ISN_LOADBDICT: |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3475 case ISN_LOADWDICT: |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3476 case ISN_LOADTDICT: |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3477 { |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3478 dict_T *d = NULL; |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3479 |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3480 switch (iptr->isn_type) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3481 { |
21401
aa7675a4a0cd
patch 8.2.1251: Vim9: warning for pointer usage, test failure undetected
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
3482 case ISN_LOADGDICT: d = get_globvar_dict(); break; |
aa7675a4a0cd
patch 8.2.1251: Vim9: warning for pointer usage, test failure undetected
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
3483 case ISN_LOADBDICT: d = curbuf->b_vars; break; |
aa7675a4a0cd
patch 8.2.1251: Vim9: warning for pointer usage, test failure undetected
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
3484 case ISN_LOADWDICT: d = curwin->w_vars; break; |
aa7675a4a0cd
patch 8.2.1251: Vim9: warning for pointer usage, test failure undetected
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
3485 case ISN_LOADTDICT: d = curtab->tp_vars; break; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3486 default: // Cannot reach here |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3487 goto theend; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3488 } |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3489 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3490 goto theend; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3491 tv = STACK_TV_BOT(0); |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3492 tv->v_type = VAR_DICT; |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3493 tv->v_lock = 0; |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3494 tv->vval.v_dict = d; |
24014
e45b2e28e45e
patch 8.2.2549: crash after using "g:" in a for loop
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
3495 ++d->dv_refcount; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3496 ++ectx->ec_stack.ga_len; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3497 } |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3498 break; |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3499 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3500 // load &option |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3501 case ISN_LOADOPT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3502 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3503 typval_T optval; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3504 char_u *name = iptr->isn_arg.string; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3505 |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
3506 // This is not expected to fail, name is checked during |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
3507 // compilation: don't set SOURCING_LNUM. |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3508 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3509 goto theend; |
21120
4d844a65183d
patch 8.2.1111: inconsistent naming of get_list_tv() and eval_dict()
Bram Moolenaar <Bram@vim.org>
parents:
20943
diff
changeset
|
3510 if (eval_option(&name, &optval, TRUE) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3511 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3512 *STACK_TV_BOT(0) = optval; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3513 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3514 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3515 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3516 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3517 // load $ENV |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3518 case ISN_LOADENV: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3519 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3520 typval_T optval; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3521 char_u *name = iptr->isn_arg.string; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3522 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3523 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3524 goto theend; |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
3525 // name is always valid, checked when compiling |
21120
4d844a65183d
patch 8.2.1111: inconsistent naming of get_list_tv() and eval_dict()
Bram Moolenaar <Bram@vim.org>
parents:
20943
diff
changeset
|
3526 (void)eval_env_var(&name, &optval, TRUE); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3527 *STACK_TV_BOT(0) = optval; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3528 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3529 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3530 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3531 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3532 // load @register |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3533 case ISN_LOADREG: |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3534 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3535 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3536 tv = STACK_TV_BOT(0); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3537 tv->v_type = VAR_STRING; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3538 tv->v_lock = 0; |
22612
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
3539 // This may result in NULL, which should be equivalent to an |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
3540 // empty string. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3541 tv->vval.v_string = get_reg_contents( |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3542 iptr->isn_arg.number, GREG_EXPR_SRC); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3543 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3544 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3545 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3546 // store local variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3547 case ISN_STORE: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3548 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3549 tv = STACK_TV_VAR(iptr->isn_arg.number); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3550 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3551 *tv = *STACK_TV_BOT(0); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3552 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3553 |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3554 // store s: variable in old script or autoload import |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3555 case ISN_STORES: |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3556 case ISN_STOREEXPORT: |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3557 { |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3558 int sid = iptr->isn_arg.loadstore.ls_sid; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3559 hashtab_T *ht = &SCRIPT_VARS(sid); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3560 char_u *name = iptr->isn_arg.loadstore.ls_name; |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3561 dictitem_T *di = find_var_in_ht(ht, 0, |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3562 iptr->isn_type == ISN_STORES |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3563 ? name + 2 : name, TRUE); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3564 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3565 --ectx->ec_stack.ga_len; |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3566 SOURCING_LNUM = iptr->isn_lnum; |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3567 if (di == NULL) |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3568 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3569 if (iptr->isn_type == ISN_STOREEXPORT) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3570 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3571 semsg(_(e_undefined_variable_str), name); |
28253
d817abf991df
patch 8.2.4652: leaking memory if assignment fails
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
3572 clear_tv(STACK_TV_BOT(0)); |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3573 goto on_error; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3574 } |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
3575 store_var(name, STACK_TV_BOT(0)); |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3576 } |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
3577 else |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3578 { |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3579 if (iptr->isn_type == ISN_STOREEXPORT) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3580 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3581 int idx = get_script_item_idx(sid, name, 0, |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3582 NULL, NULL); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3583 |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
3584 // can this ever fail? |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3585 if (idx >= 0) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3586 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3587 svar_T *sv = ((svar_T *)SCRIPT_ITEM(sid) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3588 ->sn_var_vals.ga_data) + idx; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3589 |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3590 if ((sv->sv_flags & SVFLAG_EXPORTED) == 0) |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3591 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3592 semsg(_(e_item_not_exported_in_script_str), |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3593 name); |
28253
d817abf991df
patch 8.2.4652: leaking memory if assignment fails
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
3594 clear_tv(STACK_TV_BOT(0)); |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3595 goto on_error; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3596 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3597 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
3598 } |
24305
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
3599 if (var_check_permission(di, name) == FAIL) |
24325
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
3600 { |
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
3601 clear_tv(STACK_TV_BOT(0)); |
24305
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
3602 goto on_error; |
24325
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
3603 } |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
3604 clear_tv(&di->di_tv); |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
3605 di->di_tv = *STACK_TV_BOT(0); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3606 } |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3607 } |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3608 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3609 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3610 // store script-local variable in Vim9 script |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3611 case ISN_STORESCRIPT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3612 { |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
3613 scriptref_T *sref = iptr->isn_arg.script.scriptref; |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
3614 svar_T *sv; |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
3615 |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
3616 sv = get_script_svar(sref, ectx->ec_dfunc_idx); |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
3617 if (sv == NULL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3618 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3619 --ectx->ec_stack.ga_len; |
24303
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3620 |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3621 // "const" and "final" are checked at compile time, locking |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3622 // the value needs to be checked here. |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3623 SOURCING_LNUM = iptr->isn_lnum; |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3624 if (value_check_lock(sv->sv_tv->v_lock, sv->sv_name, FALSE)) |
24325
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
3625 { |
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
3626 clear_tv(STACK_TV_BOT(0)); |
24303
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3627 goto on_error; |
24325
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
3628 } |
24303
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
3629 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3630 clear_tv(sv->sv_tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3631 *sv->sv_tv = *STACK_TV_BOT(0); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3632 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3633 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3634 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3635 // store option |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3636 case ISN_STOREOPT: |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3637 case ISN_STOREFUNCOPT: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3638 { |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3639 char_u *opt_name = iptr->isn_arg.storeopt.so_name; |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3640 int opt_flags = iptr->isn_arg.storeopt.so_flags; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3641 long n = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3642 char_u *s = NULL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3643 char *msg; |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3644 char_u numbuf[NUMBUFLEN]; |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3645 char_u *tofree = NULL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3646 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3647 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3648 tv = STACK_TV_BOT(0); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3649 if (tv->v_type == VAR_STRING) |
19219
89931701e033
patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents:
19217
diff
changeset
|
3650 { |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3651 s = tv->vval.v_string; |
19219
89931701e033
patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents:
19217
diff
changeset
|
3652 if (s == NULL) |
89931701e033
patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents:
19217
diff
changeset
|
3653 s = (char_u *)""; |
89931701e033
patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents:
19217
diff
changeset
|
3654 } |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3655 else if (iptr->isn_type == ISN_STOREFUNCOPT) |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3656 { |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3657 SOURCING_LNUM = iptr->isn_lnum; |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3658 // If the option can be set to a function reference or |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3659 // a lambda and the passed value is a function |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3660 // reference, then convert it to the name (string) of |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3661 // the function reference. |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3662 s = tv2string(tv, &tofree, numbuf, 0); |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3663 if (s == NULL || *s == NUL) |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3664 { |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
3665 // cannot happen? |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3666 clear_tv(tv); |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
3667 vim_free(tofree); |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3668 goto on_error; |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3669 } |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3670 } |
20419
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
3671 else |
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
3672 // must be VAR_NUMBER, CHECKTYPE makes sure |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3673 n = tv->vval.v_number; |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
3674 msg = set_option_value(opt_name, n, s, opt_flags); |
20427
0ab8f8880a33
patch 8.2.0768: Vim9: memory leak in script test
Bram Moolenaar <Bram@vim.org>
parents:
20419
diff
changeset
|
3675 clear_tv(tv); |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
3676 vim_free(tofree); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3677 if (msg != NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3678 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
3679 SOURCING_LNUM = iptr->isn_lnum; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3680 emsg(_(msg)); |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3681 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3682 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3683 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3684 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3685 |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3686 // store $ENV |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3687 case ISN_STOREENV: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3688 --ectx->ec_stack.ga_len; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
3689 tv = STACK_TV_BOT(0); |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
3690 vim_setenv_ext(iptr->isn_arg.string, tv_get_string(tv)); |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
3691 clear_tv(tv); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3692 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3693 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3694 // store @r |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3695 case ISN_STOREREG: |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3696 { |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3697 int reg = iptr->isn_arg.number; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3698 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3699 --ectx->ec_stack.ga_len; |
19449
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
3700 tv = STACK_TV_BOT(0); |
24956
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24954
diff
changeset
|
3701 write_reg_contents(reg, tv_get_string(tv), -1, FALSE); |
19449
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
3702 clear_tv(tv); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3703 } |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3704 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3705 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3706 // store v: variable |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3707 case ISN_STOREV: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3708 --ectx->ec_stack.ga_len; |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3709 if (set_vim_var_tv(iptr->isn_arg.number, STACK_TV_BOT(0)) |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3710 == FAIL) |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3711 // should not happen, type is checked when compiling |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3712 goto on_error; |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3713 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
3714 |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3715 // store g:/b:/w:/t: variable |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3716 case ISN_STOREG: |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3717 case ISN_STOREB: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3718 case ISN_STOREW: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3719 case ISN_STORET: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3720 { |
23295
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3721 dictitem_T *di; |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3722 hashtab_T *ht; |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3723 char_u *name = iptr->isn_arg.string + 2; |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3724 |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3725 switch (iptr->isn_type) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3726 { |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3727 case ISN_STOREG: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3728 ht = get_globvar_ht(); |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3729 break; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3730 case ISN_STOREB: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3731 ht = &curbuf->b_vars->dv_hashtab; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3732 break; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3733 case ISN_STOREW: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3734 ht = &curwin->w_vars->dv_hashtab; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3735 break; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3736 case ISN_STORET: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3737 ht = &curtab->tp_vars->dv_hashtab; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3738 break; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3739 default: // Cannot reach here |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3740 goto theend; |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
3741 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3742 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3743 --ectx->ec_stack.ga_len; |
23295
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3744 di = find_var_in_ht(ht, 0, name, TRUE); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3745 if (di == NULL) |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
3746 store_var(iptr->isn_arg.string, STACK_TV_BOT(0)); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3747 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3748 { |
23295
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3749 SOURCING_LNUM = iptr->isn_lnum; |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3750 if (var_check_permission(di, name) == FAIL) |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3751 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3752 clear_tv(&di->di_tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3753 di->di_tv = *STACK_TV_BOT(0); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3754 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3755 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3756 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3757 |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3758 // store an autoload variable |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3759 case ISN_STOREAUTO: |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3760 SOURCING_LNUM = iptr->isn_lnum; |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3761 set_var(iptr->isn_arg.string, STACK_TV_BOT(-1), TRUE); |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3762 clear_tv(STACK_TV_BOT(-1)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3763 --ectx->ec_stack.ga_len; |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3764 break; |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3765 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3766 // store number in local variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3767 case ISN_STORENR: |
19597
1098989a90ee
patch 8.2.0355: Vim9: str_val is confusing, it's a number
Bram Moolenaar <Bram@vim.org>
parents:
19572
diff
changeset
|
3768 tv = STACK_TV_VAR(iptr->isn_arg.storenr.stnr_idx); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3769 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3770 tv->v_type = VAR_NUMBER; |
19597
1098989a90ee
patch 8.2.0355: Vim9: str_val is confusing, it's a number
Bram Moolenaar <Bram@vim.org>
parents:
19572
diff
changeset
|
3771 tv->vval.v_number = iptr->isn_arg.storenr.stnr_val; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3772 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3773 |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
3774 // store value in list or dict variable |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
3775 case ISN_STOREINDEX: |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
3776 { |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3777 int res = execute_storeindex(iptr, ectx); |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3778 |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3779 if (res == FAIL) |
21576
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
3780 goto on_error; |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3781 if (res == NOTDONE) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3782 goto theend; |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
3783 } |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
3784 break; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
3785 |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
3786 // store value in list or blob range |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
3787 case ISN_STORERANGE: |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3788 if (execute_storerange(iptr, ectx) == FAIL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3789 goto on_error; |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
3790 break; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
3791 |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
3792 // Load or store variable or argument from outer scope. |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3793 case ISN_LOADOUTER: |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3794 case ISN_STOREOUTER: |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3795 { |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3796 int depth = iptr->isn_arg.outer.outer_depth; |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
3797 outer_T *outer = ectx->ec_outer_ref == NULL ? NULL |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
3798 : ectx->ec_outer_ref->or_outer; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3799 |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3800 while (depth > 1 && outer != NULL) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3801 { |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3802 outer = outer->out_up; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3803 --depth; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3804 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3805 if (outer == NULL) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3806 { |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3807 SOURCING_LNUM = iptr->isn_lnum; |
26378
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3808 if (ectx->ec_frame_idx == ectx->ec_initial_frame_idx |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3809 || ectx->ec_outer_ref == NULL) |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3810 // Possibly :def function called from legacy |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3811 // context. |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3812 emsg(_(e_closure_called_from_invalid_context)); |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3813 else |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
3814 iemsg("LOADOUTER depth more than scope levels"); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3815 goto theend; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3816 } |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
3817 if (depth < 0) |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
3818 // Variable declared in loop. May be copied if the |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
3819 // loop block has already ended. |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
3820 tv = ((typval_T *)outer->out_loop[-depth - 1] |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
3821 .stack->ga_data) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
3822 + outer->out_loop[-depth - 1].var_idx |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
3823 + iptr->isn_arg.outer.outer_idx; |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
3824 else |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
3825 // Variable declared in a function. May be copied if |
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
3826 // the function has already returned. |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
3827 tv = ((typval_T *)outer->out_stack->ga_data) |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
3828 + outer->out_frame_idx + STACK_FRAME_SIZE |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
3829 + iptr->isn_arg.outer.outer_idx; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3830 if (iptr->isn_type == ISN_LOADOUTER) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3831 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3832 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3833 goto theend; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3834 copy_tv(tv, STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3835 ++ectx->ec_stack.ga_len; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3836 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3837 else |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3838 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3839 --ectx->ec_stack.ga_len; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3840 clear_tv(tv); |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3841 *tv = *STACK_TV_BOT(0); |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3842 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3843 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3844 break; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3845 |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
3846 // unlet item in list or dict variable |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
3847 case ISN_UNLETINDEX: |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3848 if (execute_unletindex(iptr, ectx) == FAIL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3849 goto on_error; |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
3850 break; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
3851 |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
3852 // unlet range of items in list variable |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
3853 case ISN_UNLETRANGE: |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3854 if (execute_unletrange(iptr, ectx) == FAIL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
3855 goto on_error; |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
3856 break; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
3857 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3858 // push constant |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3859 case ISN_PUSHNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3860 case ISN_PUSHBOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3861 case ISN_PUSHSPEC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3862 case ISN_PUSHF: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3863 case ISN_PUSHS: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3864 case ISN_PUSHBLOB: |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3865 case ISN_PUSHFUNC: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3866 case ISN_PUSHCHANNEL: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3867 case ISN_PUSHJOB: |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3868 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3869 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3870 tv = STACK_TV_BOT(0); |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
3871 tv->v_lock = 0; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3872 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3873 switch (iptr->isn_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3874 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3875 case ISN_PUSHNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3876 tv->v_type = VAR_NUMBER; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3877 tv->vval.v_number = iptr->isn_arg.number; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3878 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3879 case ISN_PUSHBOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3880 tv->v_type = VAR_BOOL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3881 tv->vval.v_number = iptr->isn_arg.number; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3882 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3883 case ISN_PUSHSPEC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3884 tv->v_type = VAR_SPECIAL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3885 tv->vval.v_number = iptr->isn_arg.number; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3886 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3887 case ISN_PUSHF: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3888 tv->v_type = VAR_FLOAT; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3889 tv->vval.v_float = iptr->isn_arg.fnumber; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3890 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3891 case ISN_PUSHBLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3892 blob_copy(iptr->isn_arg.blob, tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3893 break; |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3894 case ISN_PUSHFUNC: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3895 tv->v_type = VAR_FUNC; |
19566
ec1eeb1b69e2
patch 8.2.0340: Vim9: function and partial types not tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
3896 if (iptr->isn_arg.string == NULL) |
ec1eeb1b69e2
patch 8.2.0340: Vim9: function and partial types not tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
3897 tv->vval.v_string = NULL; |
ec1eeb1b69e2
patch 8.2.0340: Vim9: function and partial types not tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
3898 else |
ec1eeb1b69e2
patch 8.2.0340: Vim9: function and partial types not tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
3899 tv->vval.v_string = |
ec1eeb1b69e2
patch 8.2.0340: Vim9: function and partial types not tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
3900 vim_strsave(iptr->isn_arg.string); |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3901 break; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3902 case ISN_PUSHCHANNEL: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3903 #ifdef FEAT_JOB_CHANNEL |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3904 tv->v_type = VAR_CHANNEL; |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
3905 tv->vval.v_channel = NULL; |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3906 #endif |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3907 break; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3908 case ISN_PUSHJOB: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3909 #ifdef FEAT_JOB_CHANNEL |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3910 tv->v_type = VAR_JOB; |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
3911 tv->vval.v_job = NULL; |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3912 #endif |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3913 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3914 default: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3915 tv->v_type = VAR_STRING; |
28019
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3916 tv->vval.v_string = iptr->isn_arg.string == NULL |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3917 ? NULL : vim_strsave(iptr->isn_arg.string); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3918 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3919 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3920 |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3921 case ISN_AUTOLOAD: |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3922 { |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3923 char_u *name = iptr->isn_arg.string; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3924 |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3925 (void)script_autoload(name, FALSE); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3926 if (find_func(name, TRUE)) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3927 { |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3928 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3929 goto theend; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3930 tv = STACK_TV_BOT(0); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3931 tv->v_lock = 0; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3932 ++ectx->ec_stack.ga_len; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3933 tv->v_type = VAR_FUNC; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3934 tv->vval.v_string = vim_strsave(name); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3935 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3936 else |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3937 { |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3938 int res = load_namespace_var(ectx, ISN_LOADG, iptr); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3939 |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3940 if (res == NOTDONE) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3941 goto theend; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3942 if (res == FAIL) |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3943 goto on_error; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3944 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3945 } |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3946 break; |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
3947 |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3948 case ISN_UNLET: |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3949 if (do_unlet(iptr->isn_arg.unlet.ul_name, |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3950 iptr->isn_arg.unlet.ul_forceit) == FAIL) |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3951 goto on_error; |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3952 break; |
20099
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
3953 case ISN_UNLETENV: |
28459
52ef65c0637f
patch 8.2.4754: using cached values after unsetting some environment variables
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
3954 vim_unsetenv_ext(iptr->isn_arg.unlet.ul_name); |
20099
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
3955 break; |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3956 |
25605
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3957 case ISN_LOCKUNLOCK: |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3958 { |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3959 typval_T *lval_root_save = lval_root; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3960 int res; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3961 |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3962 // Stack has the local variable, argument the whole :lock |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3963 // or :unlock command, like ISN_EXEC. |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3964 --ectx->ec_stack.ga_len; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3965 lval_root = STACK_TV_BOT(0); |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3966 res = exec_command(iptr); |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3967 clear_tv(lval_root); |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3968 lval_root = lval_root_save; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3969 if (res == FAIL) |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3970 goto on_error; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3971 } |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3972 break; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3973 |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3974 case ISN_LOCKCONST: |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3975 item_lock(STACK_TV_BOT(-1), 100, TRUE, TRUE); |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3976 break; |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3977 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3978 // create a list from items on the stack; uses a single allocation |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3979 // for the list header and the items |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3980 case ISN_NEWLIST: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3981 if (exe_newlist(iptr->isn_arg.number, ectx) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3982 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3983 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3984 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3985 // create a dict from items on the stack |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3986 case ISN_NEWDICT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3987 { |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3988 int res; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3989 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3990 SOURCING_LNUM = iptr->isn_lnum; |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3991 res = exe_newdict(iptr->isn_arg.number, ectx); |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3992 if (res == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3993 goto theend; |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3994 if (res == MAYBE) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
3995 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3996 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3997 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3998 |
28598
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
3999 case ISN_CONCAT: |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
4000 if (exe_concat(iptr->isn_arg.number, ectx) == FAIL) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
4001 goto theend; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
4002 break; |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
4003 |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4004 // create a partial with NULL value |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4005 case ISN_NEWPARTIAL: |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4006 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4007 goto theend; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4008 ++ectx->ec_stack.ga_len; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4009 tv = STACK_TV_BOT(-1); |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4010 tv->v_type = VAR_PARTIAL; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4011 tv->v_lock = 0; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4012 tv->vval.v_partial = NULL; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4013 break; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
4014 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4015 // call a :def function |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4016 case ISN_DCALL: |
22214
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
4017 SOURCING_LNUM = iptr->isn_lnum; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
4018 if (call_dfunc(iptr->isn_arg.dfunc.cdf_idx, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
4019 NULL, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
4020 iptr->isn_arg.dfunc.cdf_argcount, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4021 ectx) == FAIL) |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
4022 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4023 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4024 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4025 // call a builtin function |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4026 case ISN_BCALL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4027 SOURCING_LNUM = iptr->isn_lnum; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4028 if (call_bfunc(iptr->isn_arg.bfunc.cbf_idx, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4029 iptr->isn_arg.bfunc.cbf_argcount, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4030 ectx) == FAIL) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
4031 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4032 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4033 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4034 // call a funcref or partial |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4035 case ISN_PCALL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4036 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4037 cpfunc_T *pfunc = &iptr->isn_arg.pfunc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4038 int r; |
20433
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20427
diff
changeset
|
4039 typval_T partial_tv; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4040 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4041 SOURCING_LNUM = iptr->isn_lnum; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4042 if (pfunc->cpf_top) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4043 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4044 // funcref is above the arguments |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4045 tv = STACK_TV_BOT(-pfunc->cpf_argcount - 1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4046 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4047 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4048 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4049 // Get the funcref from the stack. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4050 --ectx->ec_stack.ga_len; |
20433
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20427
diff
changeset
|
4051 partial_tv = *STACK_TV_BOT(0); |
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20427
diff
changeset
|
4052 tv = &partial_tv; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4053 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4054 r = call_partial(tv, pfunc->cpf_argcount, ectx); |
20433
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20427
diff
changeset
|
4055 if (tv == &partial_tv) |
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20427
diff
changeset
|
4056 clear_tv(&partial_tv); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4057 if (r == FAIL) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
4058 goto on_error; |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4059 } |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4060 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4061 |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4062 case ISN_PCALL_END: |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4063 // PCALL finished, arguments have been consumed and replaced by |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4064 // the return value. Now clear the funcref from the stack, |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4065 // and move the return value in its place. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4066 --ectx->ec_stack.ga_len; |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4067 clear_tv(STACK_TV_BOT(-1)); |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
4068 *STACK_TV_BOT(-1) = *STACK_TV_BOT(0); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4069 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4070 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4071 // call a user defined function or funcref/partial |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4072 case ISN_UCALL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4073 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4074 cufunc_T *cufunc = &iptr->isn_arg.ufunc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4075 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4076 SOURCING_LNUM = iptr->isn_lnum; |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
4077 if (call_eval_func(cufunc->cuf_name, cufunc->cuf_argcount, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4078 ectx, iptr) == FAIL) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
4079 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4080 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4081 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4082 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
4083 // :defer func(arg) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
4084 case ISN_DEFER: |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
4085 if (defer_command(iptr->isn_arg.defer.defer_var_idx, |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
4086 iptr->isn_arg.defer.defer_argcount, ectx) == FAIL) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
4087 goto on_error; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
4088 break; |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
4089 |
24936
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24932
diff
changeset
|
4090 // return from a :def function call without a value |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24932
diff
changeset
|
4091 case ISN_RETURN_VOID: |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4092 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4093 goto theend; |
23543
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
4094 tv = STACK_TV_BOT(0); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4095 ++ectx->ec_stack.ga_len; |
24936
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24932
diff
changeset
|
4096 tv->v_type = VAR_VOID; |
23543
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
4097 tv->vval.v_number = 0; |
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
4098 tv->v_lock = 0; |
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
4099 // FALLTHROUGH |
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
4100 |
24936
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24932
diff
changeset
|
4101 // return from a :def function call with what is on the stack |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4102 case ISN_RETURN: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4103 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4104 garray_T *trystack = &ectx->ec_trystack; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
4105 trycmd_T *trycmd = NULL; |
19221
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
4106 |
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
4107 if (trystack->ga_len > 0) |
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
4108 trycmd = ((trycmd_T *)trystack->ga_data) |
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
4109 + trystack->ga_len - 1; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
4110 if (trycmd != NULL |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4111 && trycmd->tcd_frame_idx == ectx->ec_frame_idx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4112 { |
24002
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
4113 // jump to ":finally" or ":endtry" |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
4114 if (trycmd->tcd_finally_idx != 0) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4115 ectx->ec_iidx = trycmd->tcd_finally_idx; |
24002
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
4116 else |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4117 ectx->ec_iidx = trycmd->tcd_endtry_idx; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4118 trycmd->tcd_return = TRUE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4119 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4120 else |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
4121 goto func_return; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4122 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4123 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4124 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4125 // push a partial, a reference to a compiled function |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4126 case ISN_FUNCREF: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4127 { |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4128 partial_T *pt = ALLOC_CLEAR_ONE(partial_T); |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4129 ufunc_T *ufunc; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4130 funcref_T *funcref = &iptr->isn_arg.funcref; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4131 funcref_extra_T *extra = funcref->fr_extra; |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4132 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4133 if (pt == NULL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4134 goto theend; |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4135 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
4136 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
4137 vim_free(pt); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4138 goto theend; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
4139 } |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4140 if (extra == NULL || extra->fre_func_name == NULL) |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4141 { |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4142 dfunc_T *pt_dfunc = ((dfunc_T *)def_functions.ga_data) |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4143 + funcref->fr_dfunc_idx; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4144 |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4145 ufunc = pt_dfunc->df_ufunc; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4146 } |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
4147 else |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4148 ufunc = find_func(extra->fre_func_name, FALSE); |
27774
89b1bc6fd40a
patch 8.2.4413: Vim9: Coverity warns for using NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
4149 if (ufunc == NULL) |
89b1bc6fd40a
patch 8.2.4413: Vim9: Coverity warns for using NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
4150 { |
89b1bc6fd40a
patch 8.2.4413: Vim9: Coverity warns for using NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
4151 SOURCING_LNUM = iptr->isn_lnum; |
89b1bc6fd40a
patch 8.2.4413: Vim9: Coverity warns for using NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
4152 iemsg("ufunc unexpectedly NULL for FUNCREF"); |
89b1bc6fd40a
patch 8.2.4413: Vim9: Coverity warns for using NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
4153 goto theend; |
89b1bc6fd40a
patch 8.2.4413: Vim9: Coverity warns for using NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
4154 } |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4155 if (fill_partial_and_closure(pt, ufunc, |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
4156 extra == NULL ? NULL : &extra->fre_loopvar_info, |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4157 ectx) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4158 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4159 tv = STACK_TV_BOT(0); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4160 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4161 tv->vval.v_partial = pt; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4162 tv->v_type = VAR_PARTIAL; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
4163 tv->v_lock = 0; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4164 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4165 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4166 |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
4167 // Create a global function from a lambda. |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
4168 case ISN_NEWFUNC: |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
4169 { |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4170 newfuncarg_T *arg = iptr->isn_arg.newfunc.nf_arg; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4171 |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
4172 if (copy_lambda_to_global_func(arg->nfa_lambda, |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
4173 arg->nfa_global, &arg->nfa_loopvar_info, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
4174 ectx) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4175 goto theend; |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
4176 } |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
4177 break; |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
4178 |
22973
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4179 // List functions |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4180 case ISN_DEF: |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4181 if (iptr->isn_arg.string == NULL) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4182 list_functions(NULL); |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4183 else |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4184 { |
27026
32120100fde8
patch 8.2.4042: Vim9: build error
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
4185 exarg_T ea; |
32120100fde8
patch 8.2.4042: Vim9: build error
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
4186 garray_T lines_to_free; |
22973
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4187 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4188 CLEAR_FIELD(ea); |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4189 ea.cmd = ea.arg = iptr->isn_arg.string; |
27026
32120100fde8
patch 8.2.4042: Vim9: build error
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
4190 ga_init2(&lines_to_free, sizeof(char_u *), 50); |
32120100fde8
patch 8.2.4042: Vim9: build error
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
4191 define_function(&ea, NULL, &lines_to_free); |
32120100fde8
patch 8.2.4042: Vim9: build error
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
4192 ga_clear_strings(&lines_to_free); |
22973
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4193 } |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4194 break; |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
4195 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4196 // jump if a condition is met |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4197 case ISN_JUMP: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4198 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4199 jumpwhen_T when = iptr->isn_arg.jump.jump_when; |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4200 int error = FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4201 int jump = TRUE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4202 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4203 if (when != JUMP_ALWAYS) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4204 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4205 tv = STACK_TV_BOT(-1); |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4206 if (when == JUMP_IF_COND_FALSE |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
4207 || when == JUMP_IF_FALSE |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4208 || when == JUMP_IF_COND_TRUE) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4209 { |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4210 SOURCING_LNUM = iptr->isn_lnum; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4211 jump = tv_get_bool_chk(tv, &error); |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4212 if (error) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4213 goto on_error; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4214 } |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4215 else |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4216 jump = tv2bool(tv); |
28625
56860e29ce5d
patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28623
diff
changeset
|
4217 if (when == JUMP_IF_FALSE || when == JUMP_IF_COND_FALSE) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4218 jump = !jump; |
19334
61646c189622
patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19328
diff
changeset
|
4219 if (when == JUMP_IF_FALSE || !jump) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4220 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4221 // drop the value from the stack |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4222 clear_tv(tv); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4223 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4224 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4225 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4226 if (jump) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4227 ectx->ec_iidx = iptr->isn_arg.jump.jump_where; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4228 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4229 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4230 |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4231 // "while": jump to end if a condition is false |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4232 case ISN_WHILE: |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4233 { |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4234 int error = FALSE; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4235 int jump = TRUE; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4236 |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4237 tv = STACK_TV_BOT(-1); |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4238 SOURCING_LNUM = iptr->isn_lnum; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4239 jump = !tv_get_bool_chk(tv, &error); |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4240 if (error) |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4241 goto on_error; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4242 // drop the value from the stack |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4243 clear_tv(tv); |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4244 --ectx->ec_stack.ga_len; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4245 if (jump) |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4246 ectx->ec_iidx = iptr->isn_arg.whileloop.while_end; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4247 |
30594
586b5b3aacf9
patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents:
30564
diff
changeset
|
4248 // Store the current funcref count, may be used by |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
4249 // ISN_ENDLOOP later |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4250 tv = STACK_TV_VAR( |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4251 iptr->isn_arg.whileloop.while_funcref_idx); |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4252 tv->vval.v_number = ectx->ec_funcrefs.ga_len; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4253 } |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4254 break; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4255 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4256 // Jump if an argument with a default value was already set and not |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4257 // v:none. |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4258 case ISN_JUMP_IF_ARG_SET: |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4259 tv = STACK_TV_VAR(iptr->isn_arg.jumparg.jump_arg_off); |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4260 if (tv->v_type != VAR_UNKNOWN |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4261 && !(tv->v_type == VAR_SPECIAL |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4262 && tv->vval.v_number == VVAL_NONE)) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4263 ectx->ec_iidx = iptr->isn_arg.jumparg.jump_where; |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4264 break; |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
4265 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4266 // top of a for loop |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4267 case ISN_FOR: |
27340
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
4268 if (execute_for(iptr, ectx) == FAIL) |
2b3cc874334c
patch 8.2.4198: Vim9: the switch for executing instructions is too long
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
4269 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4270 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4271 |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4272 // end of a for or while loop |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4273 case ISN_ENDLOOP: |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4274 if (execute_endloop(iptr, ectx) == FAIL) |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4275 goto theend; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4276 break; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
4277 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4278 // start of ":try" block |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4279 case ISN_TRY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4280 { |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
4281 trycmd_T *trycmd = NULL; |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
4282 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4283 if (GA_GROW_FAILS(&ectx->ec_trystack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4284 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4285 trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4286 + ectx->ec_trystack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4287 ++ectx->ec_trystack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4288 ++trylevel; |
23934
f9a4ede76237
patch 8.2.2509: tests fail on s390 build
Bram Moolenaar <Bram@vim.org>
parents:
23927
diff
changeset
|
4289 CLEAR_POINTER(trycmd); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4290 trycmd->tcd_frame_idx = ectx->ec_frame_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4291 trycmd->tcd_stack_len = ectx->ec_stack.ga_len; |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
4292 trycmd->tcd_catch_idx = |
26672
3516017e5f54
patch 8.2.3865: Vim9: compiler complains about using "try" as a struct member
Bram Moolenaar <Bram@vim.org>
parents:
26662
diff
changeset
|
4293 iptr->isn_arg.tryref.try_ref->try_catch; |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
4294 trycmd->tcd_finally_idx = |
26672
3516017e5f54
patch 8.2.3865: Vim9: compiler complains about using "try" as a struct member
Bram Moolenaar <Bram@vim.org>
parents:
26662
diff
changeset
|
4295 iptr->isn_arg.tryref.try_ref->try_finally; |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
4296 trycmd->tcd_endtry_idx = |
26672
3516017e5f54
patch 8.2.3865: Vim9: compiler complains about using "try" as a struct member
Bram Moolenaar <Bram@vim.org>
parents:
26662
diff
changeset
|
4297 iptr->isn_arg.tryref.try_ref->try_endtry; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4298 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4299 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4300 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4301 case ISN_PUSHEXC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4302 if (current_exception == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4303 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4304 SOURCING_LNUM = iptr->isn_lnum; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4305 iemsg("Evaluating catch while current_exception is NULL"); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4306 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4307 } |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4308 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4309 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4310 tv = STACK_TV_BOT(0); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4311 ++ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4312 tv->v_type = VAR_STRING; |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
4313 tv->v_lock = 0; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4314 tv->vval.v_string = vim_strsave( |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4315 (char_u *)current_exception->value); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4316 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4317 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4318 case ISN_CATCH: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4319 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4320 garray_T *trystack = &ectx->ec_trystack; |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4321 trycmd_T *trycmd; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4322 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4323 may_restore_cmdmod(&ectx->ec_funclocal); |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4324 trycmd = ((trycmd_T *)trystack->ga_data) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4325 + trystack->ga_len - 1; |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4326 trycmd->tcd_caught = TRUE; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4327 trycmd->tcd_did_throw = FALSE; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4328 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4329 did_emsg = got_int = did_throw = FALSE; |
23656
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23650
diff
changeset
|
4330 force_abort = need_rethrow = FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4331 catch_exception(current_exception); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4332 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4333 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4334 |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4335 case ISN_TRYCONT: |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4336 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4337 garray_T *trystack = &ectx->ec_trystack; |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4338 trycont_T *trycont = &iptr->isn_arg.trycont; |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4339 int i; |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4340 trycmd_T *trycmd; |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4341 int iidx = trycont->tct_where; |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4342 |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4343 if (trystack->ga_len < trycont->tct_levels) |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4344 { |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4345 siemsg("TRYCONT: expected %d levels, found %d", |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4346 trycont->tct_levels, trystack->ga_len); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4347 goto theend; |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4348 } |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4349 // Make :endtry jump to any outer try block and the last |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4350 // :endtry inside the loop to the loop start. |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4351 for (i = trycont->tct_levels; i > 0; --i) |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4352 { |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4353 trycmd = ((trycmd_T *)trystack->ga_data) |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4354 + trystack->ga_len - i; |
24122
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24112
diff
changeset
|
4355 // Add one to tcd_cont to be able to jump to |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24112
diff
changeset
|
4356 // instruction with index zero. |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24112
diff
changeset
|
4357 trycmd->tcd_cont = iidx + 1; |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4358 iidx = trycmd->tcd_finally_idx == 0 |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4359 ? trycmd->tcd_endtry_idx : trycmd->tcd_finally_idx; |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4360 } |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4361 // jump to :finally or :endtry of current try statement |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4362 ectx->ec_iidx = iidx; |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4363 } |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4364 break; |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
4365 |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4366 case ISN_FINALLY: |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4367 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4368 garray_T *trystack = &ectx->ec_trystack; |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4369 trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data) |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4370 + trystack->ga_len - 1; |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4371 |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4372 // Reset the index to avoid a return statement jumps here |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4373 // again. |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4374 trycmd->tcd_finally_idx = 0; |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4375 break; |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4376 } |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
4377 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4378 // end of ":try" block |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4379 case ISN_ENDTRY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4380 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4381 garray_T *trystack = &ectx->ec_trystack; |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4382 trycmd_T *trycmd; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4383 |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4384 --trystack->ga_len; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4385 --trylevel; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4386 trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4387 if (trycmd->tcd_did_throw) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4388 did_throw = TRUE; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4389 if (trycmd->tcd_caught && current_exception != NULL) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4390 { |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4391 // discard the exception |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4392 if (caught_stack == current_exception) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4393 caught_stack = caught_stack->caught; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4394 discard_current_exception(); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4395 } |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4396 |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4397 if (trycmd->tcd_return) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4398 goto func_return; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4399 |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4400 while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4401 { |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4402 --ectx->ec_stack.ga_len; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4403 clear_tv(STACK_TV_BOT(0)); |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4404 } |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4405 if (trycmd->tcd_cont != 0) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4406 // handling :continue: jump to outer try block or |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4407 // start of the loop |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4408 ectx->ec_iidx = trycmd->tcd_cont - 1; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4409 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4410 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4411 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4412 case ISN_THROW: |
23618
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23604
diff
changeset
|
4413 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4414 garray_T *trystack = &ectx->ec_trystack; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4415 |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4416 if (trystack->ga_len == 0 && trylevel == 0 && emsg_silent) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4417 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4418 // throwing an exception while using "silent!" causes |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4419 // the function to abort but not display an error. |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4420 tv = STACK_TV_BOT(-1); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4421 clear_tv(tv); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4422 tv->v_type = VAR_NUMBER; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4423 tv->vval.v_number = 0; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4424 goto done; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4425 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4426 --ectx->ec_stack.ga_len; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4427 tv = STACK_TV_BOT(0); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4428 if (tv->vval.v_string == NULL |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4429 || *skipwhite(tv->vval.v_string) == NUL) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4430 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4431 vim_free(tv->vval.v_string); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4432 SOURCING_LNUM = iptr->isn_lnum; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4433 emsg(_(e_throw_with_empty_string)); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4434 goto theend; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4435 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4436 |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4437 // Inside a "catch" we need to first discard the caught |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4438 // exception. |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4439 if (trystack->ga_len > 0) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4440 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4441 trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4442 + trystack->ga_len - 1; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4443 if (trycmd->tcd_caught && current_exception != NULL) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4444 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4445 // discard the exception |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4446 if (caught_stack == current_exception) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4447 caught_stack = caught_stack->caught; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4448 discard_current_exception(); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4449 trycmd->tcd_caught = FALSE; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4450 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4451 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4452 |
27665
a6ffe874a24b
patch 8.2.4358: Vim9: line number of exception is not set
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
4453 SOURCING_LNUM = iptr->isn_lnum; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4454 if (throw_exception(tv->vval.v_string, ET_USER, NULL) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4455 == FAIL) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4456 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4457 vim_free(tv->vval.v_string); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4458 goto theend; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4459 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
4460 did_throw = TRUE; |
23618
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23604
diff
changeset
|
4461 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4462 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4463 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4464 // compare with special values |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4465 case ISN_COMPAREBOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4466 case ISN_COMPARESPECIAL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4467 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4468 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4469 typval_T *tv2 = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4470 varnumber_T arg1 = tv1->vval.v_number; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4471 varnumber_T arg2 = tv2->vval.v_number; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4472 int res; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4473 |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4474 if (iptr->isn_arg.op.op_type == EXPR_EQUAL) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4475 res = arg1 == arg2; |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4476 else |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
4477 res = arg1 != arg2; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4478 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4479 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4480 tv1->v_type = VAR_BOOL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4481 tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4482 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4483 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4484 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4485 case ISN_COMPARENULL: |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4486 { |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4487 typval_T *tv1 = STACK_TV_BOT(-2); |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4488 typval_T *tv2 = STACK_TV_BOT(-1); |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4489 int res; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4490 |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4491 res = typval_compare_null(tv1, tv2); |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4492 if (res == MAYBE) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4493 goto on_error; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4494 if (iptr->isn_arg.op.op_type == EXPR_NEQUAL) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4495 res = !res; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4496 clear_tv(tv1); |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4497 clear_tv(tv2); |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4498 --ectx->ec_stack.ga_len; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4499 tv1->v_type = VAR_BOOL; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4500 tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4501 } |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4502 break; |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
4503 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4504 // Operation with two number arguments |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4505 case ISN_OPNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4506 case ISN_COMPARENR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4507 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4508 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4509 typval_T *tv2 = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4510 varnumber_T arg1 = tv1->vval.v_number; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4511 varnumber_T arg2 = tv2->vval.v_number; |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4512 varnumber_T res = 0; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4513 int div_zero = FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4514 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4515 if (iptr->isn_arg.op.op_type == EXPR_LSHIFT |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4516 || iptr->isn_arg.op.op_type == EXPR_RSHIFT) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4517 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4518 if (arg2 < 0) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4519 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4520 SOURCING_LNUM = iptr->isn_lnum; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4521 emsg(_(e_bitshift_ops_must_be_postive)); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4522 goto on_error; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4523 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4524 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4525 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4526 switch (iptr->isn_arg.op.op_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4527 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4528 case EXPR_MULT: res = arg1 * arg2; break; |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4529 case EXPR_DIV: if (arg2 == 0) |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4530 div_zero = TRUE; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4531 else |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4532 res = arg1 / arg2; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4533 break; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4534 case EXPR_REM: if (arg2 == 0) |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4535 div_zero = TRUE; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4536 else |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4537 res = arg1 % arg2; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4538 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4539 case EXPR_SUB: res = arg1 - arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4540 case EXPR_ADD: res = arg1 + arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4541 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4542 case EXPR_EQUAL: res = arg1 == arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4543 case EXPR_NEQUAL: res = arg1 != arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4544 case EXPR_GREATER: res = arg1 > arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4545 case EXPR_GEQUAL: res = arg1 >= arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4546 case EXPR_SMALLER: res = arg1 < arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4547 case EXPR_SEQUAL: res = arg1 <= arg2; break; |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4548 case EXPR_LSHIFT: if (arg2 > MAX_LSHIFT_BITS) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4549 res = 0; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4550 else |
28968
3043a3e2ef95
patch 8.2.5006: asan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
4551 res = (uvarnumber_T)arg1 << arg2; |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4552 break; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4553 case EXPR_RSHIFT: if (arg2 > MAX_LSHIFT_BITS) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4554 res = 0; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4555 else |
28964
8973f2f00872
patch 8.2.5004: right shift on negative number does not work as documented
Bram Moolenaar <Bram@vim.org>
parents:
28962
diff
changeset
|
4556 res = (uvarnumber_T)arg1 >> arg2; |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
4557 break; |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4558 default: break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4559 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4560 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4561 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4562 if (iptr->isn_type == ISN_COMPARENR) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4563 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4564 tv1->v_type = VAR_BOOL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4565 tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4566 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4567 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4568 tv1->vval.v_number = res; |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4569 if (div_zero) |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4570 { |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4571 SOURCING_LNUM = iptr->isn_lnum; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4572 emsg(_(e_divide_by_zero)); |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4573 goto on_error; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
4574 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4575 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4576 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4577 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4578 // Computation with two float arguments |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4579 case ISN_OPFLOAT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4580 case ISN_COMPAREFLOAT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4581 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4582 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4583 typval_T *tv2 = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4584 float_T arg1 = tv1->vval.v_float; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4585 float_T arg2 = tv2->vval.v_float; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4586 float_T res = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4587 int cmp = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4588 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4589 switch (iptr->isn_arg.op.op_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4590 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4591 case EXPR_MULT: res = arg1 * arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4592 case EXPR_DIV: res = arg1 / arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4593 case EXPR_SUB: res = arg1 - arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4594 case EXPR_ADD: res = arg1 + arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4595 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4596 case EXPR_EQUAL: cmp = arg1 == arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4597 case EXPR_NEQUAL: cmp = arg1 != arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4598 case EXPR_GREATER: cmp = arg1 > arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4599 case EXPR_GEQUAL: cmp = arg1 >= arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4600 case EXPR_SMALLER: cmp = arg1 < arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4601 case EXPR_SEQUAL: cmp = arg1 <= arg2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4602 default: cmp = 0; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4603 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4604 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4605 if (iptr->isn_type == ISN_COMPAREFLOAT) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4606 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4607 tv1->v_type = VAR_BOOL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4608 tv1->vval.v_number = cmp ? VVAL_TRUE : VVAL_FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4609 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4610 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4611 tv1->vval.v_float = res; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4612 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4613 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4614 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4615 case ISN_COMPARELIST: |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4616 case ISN_COMPAREDICT: |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4617 case ISN_COMPAREFUNC: |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4618 case ISN_COMPARESTRING: |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4619 case ISN_COMPAREBLOB: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4620 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4621 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4622 typval_T *tv2 = STACK_TV_BOT(-1); |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4623 exprtype_T exprtype = iptr->isn_arg.op.op_type; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4624 int ic = iptr->isn_arg.op.op_ic; |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4625 int res = FALSE; |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4626 int status = OK; |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4627 |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4628 SOURCING_LNUM = iptr->isn_lnum; |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4629 if (iptr->isn_type == ISN_COMPARELIST) |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4630 { |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4631 status = typval_compare_list(tv1, tv2, |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4632 exprtype, ic, &res); |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4633 } |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4634 else if (iptr->isn_type == ISN_COMPAREDICT) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4635 { |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4636 status = typval_compare_dict(tv1, tv2, |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4637 exprtype, ic, &res); |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4638 } |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4639 else if (iptr->isn_type == ISN_COMPAREFUNC) |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4640 { |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4641 status = typval_compare_func(tv1, tv2, |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4642 exprtype, ic, &res); |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4643 } |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4644 else if (iptr->isn_type == ISN_COMPARESTRING) |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4645 { |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4646 status = typval_compare_string(tv1, tv2, |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4647 exprtype, ic, &res); |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4648 } |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4649 else |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4650 { |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4651 status = typval_compare_blob(tv1, tv2, exprtype, &res); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4652 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4653 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4654 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4655 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4656 tv1->v_type = VAR_BOOL; |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4657 tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE; |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4658 if (status == FAIL) |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4659 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4660 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4661 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4662 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4663 case ISN_COMPAREANY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4664 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4665 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4666 typval_T *tv2 = STACK_TV_BOT(-1); |
23553
5c094273c015
patch 8.2.2319: "exptype_T" can be read as "expected type"
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
4667 exprtype_T exprtype = iptr->isn_arg.op.op_type; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4668 int ic = iptr->isn_arg.op.op_ic; |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4669 int status; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4670 |
22262
3f082bd15d29
patch 8.2.1680: Vim9: line number for compare error is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
4671 SOURCING_LNUM = iptr->isn_lnum; |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4672 status = typval_compare(tv1, tv2, exprtype, ic); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4673 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4674 --ectx->ec_stack.ga_len; |
26644
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4675 if (status == FAIL) |
2fc1e528e0e1
patch 8.2.3851: Vim9: overhead when comparing string, dict or function
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
4676 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4677 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4678 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4679 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4680 case ISN_ADDLIST: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4681 case ISN_ADDBLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4682 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4683 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4684 typval_T *tv2 = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4685 |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4686 // add two lists or blobs |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4687 if (iptr->isn_type == ISN_ADDLIST) |
25776
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4688 { |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4689 if (iptr->isn_arg.op.op_type == EXPR_APPEND |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4690 && tv1->vval.v_list != NULL) |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4691 list_extend(tv1->vval.v_list, tv2->vval.v_list, |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4692 NULL); |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4693 else |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4694 eval_addlist(tv1, tv2); |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
4695 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4696 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4697 eval_addblob(tv1, tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4698 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4699 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4700 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4701 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4702 |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4703 case ISN_LISTAPPEND: |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4704 { |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4705 typval_T *tv1 = STACK_TV_BOT(-2); |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4706 typval_T *tv2 = STACK_TV_BOT(-1); |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4707 list_T *l = tv1->vval.v_list; |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4708 |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4709 // add an item to a list |
26891
902b8bee5254
patch 8.2.3974: Vim9: LISTAPPEND instruction does not check for a locked list
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
4710 SOURCING_LNUM = iptr->isn_lnum; |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4711 if (l == NULL) |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4712 { |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4713 emsg(_(e_cannot_add_to_null_list)); |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4714 goto on_error; |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4715 } |
26891
902b8bee5254
patch 8.2.3974: Vim9: LISTAPPEND instruction does not check for a locked list
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
4716 if (value_check_lock(l->lv_lock, NULL, FALSE)) |
902b8bee5254
patch 8.2.3974: Vim9: LISTAPPEND instruction does not check for a locked list
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
4717 goto on_error; |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4718 if (list_append_tv(l, tv2) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4719 goto theend; |
22641
6dce588f7a46
patch 8.2.1869: Vim9: memory leak when using add()
Bram Moolenaar <Bram@vim.org>
parents:
22637
diff
changeset
|
4720 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4721 --ectx->ec_stack.ga_len; |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4722 } |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4723 break; |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
4724 |
22637
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4725 case ISN_BLOBAPPEND: |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4726 { |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4727 typval_T *tv1 = STACK_TV_BOT(-2); |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4728 typval_T *tv2 = STACK_TV_BOT(-1); |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4729 blob_T *b = tv1->vval.v_blob; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4730 int error = FALSE; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4731 varnumber_T n; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4732 |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4733 // add a number to a blob |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4734 if (b == NULL) |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4735 { |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4736 SOURCING_LNUM = iptr->isn_lnum; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4737 emsg(_(e_cannot_add_to_null_blob)); |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4738 goto on_error; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4739 } |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4740 n = tv_get_number_chk(tv2, &error); |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4741 if (error) |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4742 goto on_error; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4743 ga_append(&b->bv_ga, (int)n); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4744 --ectx->ec_stack.ga_len; |
22637
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4745 } |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4746 break; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
4747 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4748 // Computation with two arguments of unknown type |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4749 case ISN_OPANY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4750 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4751 typval_T *tv1 = STACK_TV_BOT(-2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4752 typval_T *tv2 = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4753 varnumber_T n1, n2; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4754 float_T f1 = 0, f2 = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4755 int error = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4756 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4757 if (iptr->isn_arg.op.op_type == EXPR_ADD) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4758 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4759 if (tv1->v_type == VAR_LIST && tv2->v_type == VAR_LIST) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4760 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4761 eval_addlist(tv1, tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4762 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4763 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4764 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4765 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4766 else if (tv1->v_type == VAR_BLOB |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4767 && tv2->v_type == VAR_BLOB) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4768 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4769 eval_addblob(tv1, tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4770 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4771 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4772 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4773 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4774 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4775 if (tv1->v_type == VAR_FLOAT) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4776 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4777 f1 = tv1->vval.v_float; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4778 n1 = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4779 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4780 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4781 { |
23100
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
4782 SOURCING_LNUM = iptr->isn_lnum; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4783 n1 = tv_get_number_chk(tv1, &error); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4784 if (error) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
4785 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4786 if (tv2->v_type == VAR_FLOAT) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4787 f1 = n1; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4788 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4789 if (tv2->v_type == VAR_FLOAT) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4790 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4791 f2 = tv2->vval.v_float; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4792 n2 = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4793 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4794 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4795 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4796 n2 = tv_get_number_chk(tv2, &error); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4797 if (error) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
4798 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4799 if (tv1->v_type == VAR_FLOAT) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4800 f2 = n2; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4801 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4802 // if there is a float on either side the result is a float |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4803 if (tv1->v_type == VAR_FLOAT || tv2->v_type == VAR_FLOAT) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4804 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4805 switch (iptr->isn_arg.op.op_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4806 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4807 case EXPR_MULT: f1 = f1 * f2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4808 case EXPR_DIV: f1 = f1 / f2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4809 case EXPR_SUB: f1 = f1 - f2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4810 case EXPR_ADD: f1 = f1 + f2; break; |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4811 default: SOURCING_LNUM = iptr->isn_lnum; |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4812 emsg(_(e_cannot_use_percent_with_float)); |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4813 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4814 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4815 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4816 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4817 tv1->v_type = VAR_FLOAT; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4818 tv1->vval.v_float = f1; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4819 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4820 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4821 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4822 { |
23681
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
4823 int failed = FALSE; |
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
4824 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4825 switch (iptr->isn_arg.op.op_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4826 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4827 case EXPR_MULT: n1 = n1 * n2; break; |
23681
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
4828 case EXPR_DIV: n1 = num_divide(n1, n2, &failed); |
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
4829 if (failed) |
23673
6d35bc0f161e
patch 8.2.2378: Vim9: no error message for dividing by zero
Bram Moolenaar <Bram@vim.org>
parents:
23671
diff
changeset
|
4830 goto on_error; |
6d35bc0f161e
patch 8.2.2378: Vim9: no error message for dividing by zero
Bram Moolenaar <Bram@vim.org>
parents:
23671
diff
changeset
|
4831 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4832 case EXPR_SUB: n1 = n1 - n2; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4833 case EXPR_ADD: n1 = n1 + n2; break; |
23681
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
4834 default: n1 = num_modulus(n1, n2, &failed); |
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
4835 if (failed) |
23673
6d35bc0f161e
patch 8.2.2378: Vim9: no error message for dividing by zero
Bram Moolenaar <Bram@vim.org>
parents:
23671
diff
changeset
|
4836 goto on_error; |
6d35bc0f161e
patch 8.2.2378: Vim9: no error message for dividing by zero
Bram Moolenaar <Bram@vim.org>
parents:
23671
diff
changeset
|
4837 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4838 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4839 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4840 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4841 tv1->v_type = VAR_NUMBER; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4842 tv1->vval.v_number = n1; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4843 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4844 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4845 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4846 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4847 |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4848 case ISN_STRINDEX: |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4849 case ISN_STRSLICE: |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4850 { |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4851 int is_slice = iptr->isn_type == ISN_STRSLICE; |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4852 varnumber_T n1 = 0, n2; |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4853 char_u *res; |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4854 |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4855 // string index: string is at stack-2, index at stack-1 |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4856 // string slice: string is at stack-3, first index at |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4857 // stack-2, second index at stack-1 |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4858 if (is_slice) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4859 { |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4860 tv = STACK_TV_BOT(-2); |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4861 n1 = tv->vval.v_number; |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4862 } |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4863 |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4864 tv = STACK_TV_BOT(-1); |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4865 n2 = tv->vval.v_number; |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4866 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4867 ectx->ec_stack.ga_len -= is_slice ? 2 : 1; |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4868 tv = STACK_TV_BOT(-1); |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4869 if (is_slice) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4870 // Slice: Select the characters from the string |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
4871 res = string_slice(tv->vval.v_string, n1, n2, FALSE); |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4872 else |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4873 // Index: The resulting variable is a string of a |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
4874 // single character (including composing characters). |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
4875 // If the index is too big or negative the result is |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
4876 // empty. |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4877 res = char_from_string(tv->vval.v_string, n2); |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4878 vim_free(tv->vval.v_string); |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4879 tv->vval.v_string = res; |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4880 } |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4881 break; |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4882 |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4883 case ISN_LISTINDEX: |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4884 case ISN_LISTSLICE: |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4885 case ISN_BLOBINDEX: |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4886 case ISN_BLOBSLICE: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4887 { |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4888 int is_slice = iptr->isn_type == ISN_LISTSLICE |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4889 || iptr->isn_type == ISN_BLOBSLICE; |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4890 int is_blob = iptr->isn_type == ISN_BLOBINDEX |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4891 || iptr->isn_type == ISN_BLOBSLICE; |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4892 varnumber_T n1, n2; |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4893 typval_T *val_tv; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4894 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4895 // list index: list is at stack-2, index at stack-1 |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4896 // list slice: list is at stack-3, indexes at stack-2 and |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4897 // stack-1 |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4898 // Same for blob. |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4899 val_tv = is_slice ? STACK_TV_BOT(-3) : STACK_TV_BOT(-2); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4900 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4901 tv = STACK_TV_BOT(-1); |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4902 n1 = n2 = tv->vval.v_number; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4903 clear_tv(tv); |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4904 |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4905 if (is_slice) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4906 { |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4907 tv = STACK_TV_BOT(-2); |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4908 n1 = tv->vval.v_number; |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4909 clear_tv(tv); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4910 } |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4911 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4912 ectx->ec_stack.ga_len -= is_slice ? 2 : 1; |
21166
64f664f9b23a
patch 8.2.1134: Vim9: getting a list member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21152
diff
changeset
|
4913 tv = STACK_TV_BOT(-1); |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21835
diff
changeset
|
4914 SOURCING_LNUM = iptr->isn_lnum; |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4915 if (is_blob) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4916 { |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4917 if (blob_slice_or_index(val_tv->vval.v_blob, is_slice, |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4918 n1, n2, FALSE, tv) == FAIL) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4919 goto on_error; |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4920 } |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4921 else |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4922 { |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4923 if (list_slice_or_index(val_tv->vval.v_list, is_slice, |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4924 n1, n2, FALSE, tv, TRUE) == FAIL) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4925 goto on_error; |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4926 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4927 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4928 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4929 |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4930 case ISN_ANYINDEX: |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4931 case ISN_ANYSLICE: |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4932 { |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4933 int is_slice = iptr->isn_type == ISN_ANYSLICE; |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4934 typval_T *var1, *var2; |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4935 int res; |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4936 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4937 // index: composite is at stack-2, index at stack-1 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4938 // slice: composite is at stack-3, indexes at stack-2 and |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4939 // stack-1 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4940 tv = is_slice ? STACK_TV_BOT(-3) : STACK_TV_BOT(-2); |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
4941 SOURCING_LNUM = iptr->isn_lnum; |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4942 if (check_can_index(tv, TRUE, TRUE) == FAIL) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4943 goto on_error; |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4944 var1 = is_slice ? STACK_TV_BOT(-2) : STACK_TV_BOT(-1); |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4945 var2 = is_slice ? STACK_TV_BOT(-1) : NULL; |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
4946 res = eval_index_inner(tv, is_slice, var1, var2, |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23582
diff
changeset
|
4947 FALSE, NULL, -1, TRUE); |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4948 clear_tv(var1); |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4949 if (is_slice) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4950 clear_tv(var2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4951 ectx->ec_stack.ga_len -= is_slice ? 2 : 1; |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4952 if (res == FAIL) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4953 goto on_error; |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4954 } |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4955 break; |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4956 |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4957 case ISN_SLICE: |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4958 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4959 list_T *list; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4960 int count = iptr->isn_arg.number; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4961 |
20915
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
4962 // type will have been checked to be a list |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4963 tv = STACK_TV_BOT(-1); |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4964 list = tv->vval.v_list; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4965 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4966 // no error for short list, expect it to be checked earlier |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4967 if (list != NULL && list->lv_len >= count) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4968 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4969 list_T *newlist = list_slice(list, |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4970 count, list->lv_len - 1); |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4971 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4972 if (newlist != NULL) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4973 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4974 list_unref(list); |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4975 tv->vval.v_list = newlist; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4976 ++newlist->lv_refcount; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4977 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4978 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4979 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4980 break; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4981 |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4982 case ISN_GETITEM: |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4983 { |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4984 listitem_T *li; |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
4985 getitem_T *gi = &iptr->isn_arg.getitem; |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4986 |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
4987 // Get list item: list is at stack-1, push item. |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
4988 // List type and length is checked for when compiling. |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
4989 tv = STACK_TV_BOT(-1 - gi->gi_with_op); |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
4990 li = list_find(tv->vval.v_list, gi->gi_index); |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4991 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4992 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4993 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4994 ++ectx->ec_stack.ga_len; |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4995 copy_tv(&li->li_tv, STACK_TV_BOT(-1)); |
23917
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23839
diff
changeset
|
4996 |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23839
diff
changeset
|
4997 // Useful when used in unpack assignment. Reset at |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23839
diff
changeset
|
4998 // ISN_DROP. |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
4999 ectx->ec_where.wt_index = gi->gi_index + 1; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5000 ectx->ec_where.wt_variable = TRUE; |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
5001 } |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
5002 break; |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
5003 |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5004 case ISN_MEMBER: |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5005 { |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5006 dict_T *dict; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5007 char_u *key; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5008 dictitem_T *di; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5009 |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5010 // dict member: dict is at stack-2, key at stack-1 |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5011 tv = STACK_TV_BOT(-2); |
20411
23af9e1a5283
patch 8.2.0760: Vim9: dict member errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
20409
diff
changeset
|
5012 // no need to check for VAR_DICT, CHECKTYPE will check. |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5013 dict = tv->vval.v_dict; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5014 |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5015 tv = STACK_TV_BOT(-1); |
20411
23af9e1a5283
patch 8.2.0760: Vim9: dict member errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
20409
diff
changeset
|
5016 // no need to check for VAR_STRING, 2STRING will check. |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5017 key = tv->vval.v_string; |
22752
84fca115b1bb
patch 8.2.1924: Vim9: crash when indexing dict with NULL key
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
5018 if (key == NULL) |
84fca115b1bb
patch 8.2.1924: Vim9: crash when indexing dict with NULL key
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
5019 key = (char_u *)""; |
20411
23af9e1a5283
patch 8.2.0760: Vim9: dict member errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
20409
diff
changeset
|
5020 |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5021 if ((di = dict_find(dict, key, -1)) == NULL) |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5022 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
5023 SOURCING_LNUM = iptr->isn_lnum; |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
5024 semsg(_(e_key_not_present_in_dictionary), key); |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
5025 |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
5026 // If :silent! is used we will continue, make sure the |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5027 // stack contents makes sense and the dict stack is |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5028 // updated. |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
5029 clear_tv(tv); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5030 --ectx->ec_stack.ga_len; |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
5031 tv = STACK_TV_BOT(-1); |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5032 (void) dict_stack_save(tv); |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
5033 tv->v_type = VAR_NUMBER; |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
5034 tv->vval.v_number = 0; |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
5035 goto on_fatal_error; |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5036 } |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
5037 clear_tv(tv); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5038 --ectx->ec_stack.ga_len; |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5039 // Put the dict used on the dict stack, it might be used by |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5040 // a dict function later. |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
5041 tv = STACK_TV_BOT(-1); |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5042 if (dict_stack_save(tv) == FAIL) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5043 goto on_fatal_error; |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
5044 copy_tv(&di->di_tv, tv); |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5045 } |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5046 break; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5047 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5048 // dict member with string key |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
5049 case ISN_STRINGMEMBER: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5050 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5051 dict_T *dict; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5052 dictitem_T *di; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5053 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5054 tv = STACK_TV_BOT(-1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5055 if (tv->v_type != VAR_DICT || tv->vval.v_dict == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5056 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
5057 SOURCING_LNUM = iptr->isn_lnum; |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
5058 emsg(_(e_dictionary_required)); |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
5059 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5060 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5061 dict = tv->vval.v_dict; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5062 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5063 if ((di = dict_find(dict, iptr->isn_arg.string, -1)) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5064 == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5065 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
5066 SOURCING_LNUM = iptr->isn_lnum; |
27517
f00a7a2bee21
patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents:
27394
diff
changeset
|
5067 semsg(_(e_key_not_present_in_dictionary), |
f00a7a2bee21
patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents:
27394
diff
changeset
|
5068 iptr->isn_arg.string); |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
5069 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5070 } |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5071 // Put the dict used on the dict stack, it might be used by |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5072 // a dict function later. |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5073 if (dict_stack_save(tv) == FAIL) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5074 goto on_fatal_error; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5075 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5076 copy_tv(&di->di_tv, tv); |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5077 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5078 break; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5079 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5080 case ISN_CLEARDICT: |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5081 dict_stack_drop(); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5082 break; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5083 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5084 case ISN_USEDICT: |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5085 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5086 typval_T *dict_tv = dict_stack_get_tv(); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5087 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5088 // Turn "dict.Func" into a partial for "Func" bound to |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5089 // "dict". Don't do this when "Func" is already a partial |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5090 // that was bound explicitly (pt_auto is FALSE). |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5091 tv = STACK_TV_BOT(-1); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5092 if (dict_tv != NULL |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5093 && dict_tv->v_type == VAR_DICT |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5094 && dict_tv->vval.v_dict != NULL |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5095 && (tv->v_type == VAR_FUNC |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5096 || (tv->v_type == VAR_PARTIAL |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5097 && (tv->vval.v_partial->pt_auto |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5098 || tv->vval.v_partial->pt_dict == NULL)))) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5099 dict_tv->vval.v_dict = |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5100 make_partial(dict_tv->vval.v_dict, tv); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5101 dict_stack_drop(); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5102 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5103 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5104 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5105 case ISN_NEGATENR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5106 tv = STACK_TV_BOT(-1); |
27768
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
5107 // CHECKTYPE should have checked the variable type |
19842
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
5108 if (tv->v_type == VAR_FLOAT) |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
5109 tv->vval.v_float = -tv->vval.v_float; |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
5110 else |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
5111 tv->vval.v_number = -tv->vval.v_number; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5112 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5113 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5114 case ISN_CHECKTYPE: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5115 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5116 checktype_T *ct = &iptr->isn_arg.type; |
28901
11609f025219
patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
5117 int save_wt_variable = ectx->ec_where.wt_variable; |
28907
8f599b6d9f54
patch 8.2.4976: Coverity complains about not restoring a saved value
Bram Moolenaar <Bram@vim.org>
parents:
28901
diff
changeset
|
5118 int r; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5119 |
23697
19073a768852
patch 8.2.2390: Vim9: using positive offset is unexpected
Bram Moolenaar <Bram@vim.org>
parents:
23695
diff
changeset
|
5120 tv = STACK_TV_BOT((int)ct->ct_off); |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5121 SOURCING_LNUM = iptr->isn_lnum; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5122 if (!ectx->ec_where.wt_variable) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5123 ectx->ec_where.wt_index = ct->ct_arg_idx; |
28901
11609f025219
patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
5124 ectx->ec_where.wt_variable = ct->ct_is_var; |
28907
8f599b6d9f54
patch 8.2.4976: Coverity complains about not restoring a saved value
Bram Moolenaar <Bram@vim.org>
parents:
28901
diff
changeset
|
5125 r = check_typval_type(ct->ct_type, tv, ectx->ec_where); |
8f599b6d9f54
patch 8.2.4976: Coverity complains about not restoring a saved value
Bram Moolenaar <Bram@vim.org>
parents:
28901
diff
changeset
|
5126 ectx->ec_where.wt_variable = save_wt_variable; |
8f599b6d9f54
patch 8.2.4976: Coverity complains about not restoring a saved value
Bram Moolenaar <Bram@vim.org>
parents:
28901
diff
changeset
|
5127 if (r == FAIL) |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5128 goto on_error; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5129 if (!ectx->ec_where.wt_variable) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5130 ectx->ec_where.wt_index = 0; |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5131 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5132 // number 0 is FALSE, number 1 is TRUE |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5133 if (tv->v_type == VAR_NUMBER |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5134 && ct->ct_type->tt_type == VAR_BOOL |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5135 && (tv->vval.v_number == 0 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5136 || tv->vval.v_number == 1)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5137 { |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5138 tv->v_type = VAR_BOOL; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
5139 tv->vval.v_number = tv->vval.v_number |
22238
939f7184566f
patch 8.2.1668: Vim9: not accepting 0 or 1 as bool when type is any
Bram Moolenaar <Bram@vim.org>
parents:
22214
diff
changeset
|
5140 ? VVAL_TRUE : VVAL_FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5141 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5142 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5143 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5144 |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5145 case ISN_CHECKLEN: |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5146 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5147 int min_len = iptr->isn_arg.checklen.cl_min_len; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5148 list_T *list = NULL; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5149 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5150 tv = STACK_TV_BOT(-1); |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5151 if (tv->v_type == VAR_LIST) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5152 list = tv->vval.v_list; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5153 if (list == NULL || list->lv_len < min_len |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5154 || (list->lv_len > min_len |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5155 && !iptr->isn_arg.checklen.cl_more_OK)) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5156 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
5157 SOURCING_LNUM = iptr->isn_lnum; |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
5158 semsg(_(e_expected_nr_items_but_got_nr), |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5159 min_len, list == NULL ? 0 : list->lv_len); |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
5160 goto on_error; |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5161 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5162 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5163 break; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
5164 |
23458
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
5165 case ISN_SETTYPE: |
27517
f00a7a2bee21
patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents:
27394
diff
changeset
|
5166 set_tv_type(STACK_TV_BOT(-1), iptr->isn_arg.type.ct_type); |
23458
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
5167 break; |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
5168 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5169 case ISN_2BOOL: |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5170 case ISN_COND2BOOL: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5171 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5172 int n; |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5173 int error = FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5174 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5175 if (iptr->isn_type == ISN_2BOOL) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5176 { |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
5177 tv = STACK_TV_BOT(iptr->isn_arg.tobool.offset); |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5178 n = tv2bool(tv); |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
5179 if (iptr->isn_arg.tobool.invert) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5180 n = !n; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5181 } |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5182 else |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5183 { |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
5184 tv = STACK_TV_BOT(-1); |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5185 SOURCING_LNUM = iptr->isn_lnum; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5186 n = tv_get_bool_chk(tv, &error); |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5187 if (error) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5188 goto on_error; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
5189 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5190 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5191 tv->v_type = VAR_BOOL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5192 tv->vval.v_number = n ? VVAL_TRUE : VVAL_FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5193 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5194 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5195 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5196 case ISN_2STRING: |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
5197 case ISN_2STRING_ANY: |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
5198 SOURCING_LNUM = iptr->isn_lnum; |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
5199 if (do_2string(STACK_TV_BOT(iptr->isn_arg.tostring.offset), |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
5200 iptr->isn_type == ISN_2STRING_ANY, |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
5201 iptr->isn_arg.tostring.tolerant) == FAIL) |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
5202 goto on_error; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5203 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5204 |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5205 case ISN_RANGE: |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5206 { |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5207 exarg_T ea; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5208 char *errormsg; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5209 |
23541
a2a38bc68dd9
patch 8.2.2313: Vim9: using uninitialized field when parsing range
Bram Moolenaar <Bram@vim.org>
parents:
23527
diff
changeset
|
5210 ea.line2 = 0; |
23513
872239543313
patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
5211 ea.addr_count = 0; |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5212 ea.addr_type = ADDR_LINES; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5213 ea.cmd = iptr->isn_arg.string; |
23541
a2a38bc68dd9
patch 8.2.2313: Vim9: using uninitialized field when parsing range
Bram Moolenaar <Bram@vim.org>
parents:
23527
diff
changeset
|
5214 ea.skip = FALSE; |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5215 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) |
23541
a2a38bc68dd9
patch 8.2.2313: Vim9: using uninitialized field when parsing range
Bram Moolenaar <Bram@vim.org>
parents:
23527
diff
changeset
|
5216 goto on_error; |
23671
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5217 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
5218 if (GA_GROW_FAILS(&ectx->ec_stack, 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5219 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5220 ++ectx->ec_stack.ga_len; |
23671
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5221 tv = STACK_TV_BOT(-1); |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5222 tv->v_type = VAR_NUMBER; |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5223 tv->v_lock = 0; |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
5224 tv->vval.v_number = ea.line2; |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5225 } |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5226 break; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5227 |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5228 case ISN_PUT: |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5229 { |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5230 int regname = iptr->isn_arg.put.put_regname; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5231 linenr_T lnum = iptr->isn_arg.put.put_lnum; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5232 char_u *expr = NULL; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5233 int dir = FORWARD; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5234 |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5235 if (lnum < -2) |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5236 { |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5237 // line number was put on the stack by ISN_RANGE |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5238 tv = STACK_TV_BOT(-1); |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5239 curwin->w_cursor.lnum = tv->vval.v_number; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5240 if (lnum == LNUM_VARIABLE_RANGE_ABOVE) |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5241 dir = BACKWARD; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5242 --ectx->ec_stack.ga_len; |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5243 } |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
5244 else if (lnum == -2) |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5245 // :put! above cursor |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5246 dir = BACKWARD; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5247 else if (lnum >= 0) |
27585
a31dd0a3cb39
patch 8.2.4319: :put does not work properly in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
5248 { |
a31dd0a3cb39
patch 8.2.4319: :put does not work properly in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
5249 curwin->w_cursor.lnum = lnum; |
a31dd0a3cb39
patch 8.2.4319: :put does not work properly in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
5250 if (lnum == 0) |
a31dd0a3cb39
patch 8.2.4319: :put does not work properly in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
5251 // check_cursor() below will move to line 1 |
a31dd0a3cb39
patch 8.2.4319: :put does not work properly in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
5252 dir = BACKWARD; |
a31dd0a3cb39
patch 8.2.4319: :put does not work properly in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
5253 } |
23671
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5254 |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5255 if (regname == '=') |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5256 { |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5257 tv = STACK_TV_BOT(-1); |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5258 if (tv->v_type == VAR_STRING) |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5259 expr = tv->vval.v_string; |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5260 else |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5261 { |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5262 expr = typval2string(tv, TRUE); // allocates value |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5263 clear_tv(tv); |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5264 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5265 --ectx->ec_stack.ga_len; |
23671
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
5266 } |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5267 check_cursor(); |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5268 do_put(regname, expr, dir, 1L, PUT_LINE|PUT_CURSLINE); |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5269 vim_free(expr); |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5270 } |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5271 break; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
5272 |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5273 case ISN_CMDMOD: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5274 ectx->ec_funclocal.floc_save_cmdmod = cmdmod; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5275 ectx->ec_funclocal.floc_restore_cmdmod = TRUE; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5276 ectx->ec_funclocal.floc_restore_cmdmod_stacklen = |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5277 ectx->ec_stack.ga_len; |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5278 cmdmod = *iptr->isn_arg.cmdmod.cf_cmdmod; |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5279 apply_cmdmod(&cmdmod); |
22691
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
5280 break; |
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
5281 |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5282 case ISN_CMDMOD_REV: |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5283 // filter regprog is owned by the instruction, don't free it |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5284 cmdmod.cmod_filter_regmatch.regprog = NULL; |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5285 undo_cmdmod(&cmdmod); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5286 cmdmod = ectx->ec_funclocal.floc_save_cmdmod; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5287 ectx->ec_funclocal.floc_restore_cmdmod = FALSE; |
22691
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
5288 break; |
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
5289 |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5290 case ISN_UNPACK: |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5291 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5292 int count = iptr->isn_arg.unpack.unp_count; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5293 int semicolon = iptr->isn_arg.unpack.unp_semicolon; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5294 list_T *l; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5295 listitem_T *li; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5296 int i; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5297 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5298 // Check there is a valid list to unpack. |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5299 tv = STACK_TV_BOT(-1); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5300 if (tv->v_type != VAR_LIST) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5301 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5302 SOURCING_LNUM = iptr->isn_lnum; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5303 emsg(_(e_for_argument_must_be_sequence_of_lists)); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5304 goto on_error; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5305 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5306 l = tv->vval.v_list; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5307 if (l == NULL |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5308 || l->lv_len < (semicolon ? count - 1 : count)) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5309 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5310 SOURCING_LNUM = iptr->isn_lnum; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5311 emsg(_(e_list_value_does_not_have_enough_items)); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5312 goto on_error; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5313 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5314 else if (!semicolon && l->lv_len > count) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5315 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5316 SOURCING_LNUM = iptr->isn_lnum; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5317 emsg(_(e_list_value_has_more_items_than_targets)); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5318 goto on_error; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5319 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5320 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5321 CHECK_LIST_MATERIALIZE(l); |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
5322 if (GA_GROW_FAILS(&ectx->ec_stack, count - 1)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5323 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5324 ectx->ec_stack.ga_len += count - 1; |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5325 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5326 // Variable after semicolon gets a list with the remaining |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5327 // items. |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5328 if (semicolon) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5329 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5330 list_T *rem_list = |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5331 list_alloc_with_items(l->lv_len - count + 1); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5332 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5333 if (rem_list == NULL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5334 goto theend; |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5335 tv = STACK_TV_BOT(-count); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5336 tv->vval.v_list = rem_list; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5337 ++rem_list->lv_refcount; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5338 tv->v_lock = 0; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5339 li = l->lv_first; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5340 for (i = 0; i < count - 1; ++i) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5341 li = li->li_next; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5342 for (i = 0; li != NULL; ++i) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5343 { |
28125
ed151877ebac
patch 8.2.4587: Vim9: double free after unpacking a list
Bram Moolenaar <Bram@vim.org>
parents:
28101
diff
changeset
|
5344 typval_T tvcopy; |
ed151877ebac
patch 8.2.4587: Vim9: double free after unpacking a list
Bram Moolenaar <Bram@vim.org>
parents:
28101
diff
changeset
|
5345 |
ed151877ebac
patch 8.2.4587: Vim9: double free after unpacking a list
Bram Moolenaar <Bram@vim.org>
parents:
28101
diff
changeset
|
5346 copy_tv(&li->li_tv, &tvcopy); |
ed151877ebac
patch 8.2.4587: Vim9: double free after unpacking a list
Bram Moolenaar <Bram@vim.org>
parents:
28101
diff
changeset
|
5347 list_set_item(rem_list, i, &tvcopy); |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5348 li = li->li_next; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5349 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5350 --count; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5351 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5352 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5353 // Produce the values in reverse order, first item last. |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5354 li = l->lv_first; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5355 for (i = 0; i < count; ++i) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5356 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5357 tv = STACK_TV_BOT(-i - 1); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5358 copy_tv(&li->li_tv, tv); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5359 li = li->li_next; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5360 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5361 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5362 list_unref(l); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5363 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5364 break; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5365 |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5366 case ISN_PROF_START: |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5367 case ISN_PROF_END: |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5368 { |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
5369 #ifdef FEAT_PROFILE |
30124
9874afdacb5f
patch 9.0.0398: members of funccall_T are inconsistently named
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
5370 funccall_T cookie; |
9874afdacb5f
patch 9.0.0398: members of funccall_T are inconsistently named
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
5371 ufunc_T *cur_ufunc = |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5372 (((dfunc_T *)def_functions.ga_data) |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
5373 + ectx->ec_dfunc_idx)->df_ufunc; |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5374 |
30124
9874afdacb5f
patch 9.0.0398: members of funccall_T are inconsistently named
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
5375 cookie.fc_func = cur_ufunc; |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5376 if (iptr->isn_type == ISN_PROF_START) |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5377 { |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5378 func_line_start(&cookie, iptr->isn_lnum); |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5379 // if we get here the instruction is executed |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5380 func_line_exec(&cookie); |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5381 } |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5382 else |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5383 func_line_end(&cookie); |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
5384 #endif |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5385 } |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5386 break; |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5387 |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5388 case ISN_DEBUG: |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
5389 handle_debug(iptr, ectx); |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5390 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5391 |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5392 case ISN_SHUFFLE: |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5393 { |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5394 typval_T tmp_tv; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5395 int item = iptr->isn_arg.shuffle.shfl_item; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5396 int up = iptr->isn_arg.shuffle.shfl_up; |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5397 |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5398 tmp_tv = *STACK_TV_BOT(-item); |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5399 for ( ; up > 0 && item > 1; --up) |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5400 { |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5401 *STACK_TV_BOT(-item) = *STACK_TV_BOT(-item + 1); |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5402 --item; |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5403 } |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5404 *STACK_TV_BOT(-item) = tmp_tv; |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5405 } |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5406 break; |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
5407 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5408 case ISN_DROP: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5409 --ectx->ec_stack.ga_len; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5410 clear_tv(STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5411 ectx->ec_where.wt_index = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5412 ectx->ec_where.wt_variable = FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5413 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5414 } |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
5415 continue; |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
5416 |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
5417 func_return: |
22314
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22310
diff
changeset
|
5418 // Restore previous function. If the frame pointer is where we started |
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22310
diff
changeset
|
5419 // then there is none and we are done. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5420 if (ectx->ec_frame_idx == ectx->ec_initial_frame_idx) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
5421 goto done; |
22314
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22310
diff
changeset
|
5422 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5423 if (func_return(ectx) == FAIL) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
5424 // only fails when out of memory |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5425 goto theend; |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21401
diff
changeset
|
5426 continue; |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
5427 |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
5428 on_error: |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
5429 // Jump here for an error that does not require aborting execution. |
23102
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
5430 // If "emsg_silent" is set then ignore the error, unless it was set |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
5431 // when calling the function. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5432 if (did_emsg_cumul + did_emsg == ectx->ec_did_emsg_before |
23102
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
5433 && emsg_silent && did_emsg_def == 0) |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5434 { |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5435 // If a sequence of instructions causes an error while ":silent!" |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5436 // was used, restore the stack length and jump ahead to restoring |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5437 // the cmdmod. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5438 if (ectx->ec_funclocal.floc_restore_cmdmod) |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5439 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5440 while (ectx->ec_stack.ga_len |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5441 > ectx->ec_funclocal.floc_restore_cmdmod_stacklen) |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5442 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5443 --ectx->ec_stack.ga_len; |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5444 clear_tv(STACK_TV_BOT(0)); |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5445 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5446 while (ectx->ec_instr[ectx->ec_iidx].isn_type != ISN_CMDMOD_REV) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5447 ++ectx->ec_iidx; |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5448 } |
22760
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22758
diff
changeset
|
5449 continue; |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
5450 } |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
5451 on_fatal_error: |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
5452 // Jump here for an error that messes up the stack. |
22736
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22715
diff
changeset
|
5453 // If we are not inside a try-catch started here, abort execution. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5454 if (trylevel <= ectx->ec_trylevel_at_start) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5455 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5456 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5457 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5458 done: |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5459 ret = OK; |
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5460 theend: |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5461 may_invoke_defer_funcs(ectx); |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
5462 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
5463 dict_stack_clear(dict_stack_len_at_start); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5464 ectx->ec_trylevel_at_start = save_trylevel_at_start; |
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
5465 return ret; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5466 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5467 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5468 /* |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30071
diff
changeset
|
5469 * Execute the instructions from a VAR_INSTR typval and put the result in |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5470 * "rettv". |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5471 * Return OK or FAIL. |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5472 */ |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5473 int |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5474 exe_typval_instr(typval_T *tv, typval_T *rettv) |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5475 { |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5476 ectx_T *ectx = tv->vval.v_instr->instr_ectx; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5477 isn_T *save_instr = ectx->ec_instr; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5478 int save_iidx = ectx->ec_iidx; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5479 int res; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5480 |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28625
diff
changeset
|
5481 // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28625
diff
changeset
|
5482 // even when the compilation fails. |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28625
diff
changeset
|
5483 rettv->v_type = VAR_UNKNOWN; |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28625
diff
changeset
|
5484 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5485 ectx->ec_instr = tv->vval.v_instr->instr_instr; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5486 res = exec_instructions(ectx); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5487 if (res == OK) |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5488 { |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5489 *rettv = *STACK_TV_BOT(-1); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5490 --ectx->ec_stack.ga_len; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5491 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5492 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5493 ectx->ec_instr = save_instr; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5494 ectx->ec_iidx = save_iidx; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5495 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5496 return res; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5497 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5498 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5499 /* |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5500 * Execute the instructions from an ISN_SUBSTITUTE command, which are in |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5501 * "substitute_instr". |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5502 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5503 char_u * |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5504 exe_substitute_instr(void) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5505 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5506 ectx_T *ectx = substitute_instr->subs_ectx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5507 isn_T *save_instr = ectx->ec_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5508 int save_iidx = ectx->ec_iidx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5509 char_u *res; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5510 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5511 ectx->ec_instr = substitute_instr->subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5512 if (exec_instructions(ectx) == OK) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
5513 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5514 typval_T *tv = STACK_TV_BOT(-1); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5515 |
24816
1bed37e82c2e
patch 8.2.2946: Vim9: substitute expression cannot be a List
Bram Moolenaar <Bram@vim.org>
parents:
24812
diff
changeset
|
5516 res = typval2string(tv, TRUE); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5517 --ectx->ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5518 clear_tv(tv); |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
5519 } |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
5520 else |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
5521 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5522 substitute_instr->subs_status = FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5523 res = vim_strsave((char_u *)""); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5524 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5525 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5526 ectx->ec_instr = save_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5527 ectx->ec_iidx = save_iidx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5528 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5529 return res; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5530 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5531 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5532 /* |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5533 * Call a "def" function from old Vim script. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5534 * Return OK or FAIL. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5535 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5536 int |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5537 call_def_function( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5538 ufunc_T *ufunc, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5539 int argc_arg, // nr of arguments |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5540 typval_T *argv, // arguments |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5541 int flags, // DEF_ flags |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5542 partial_T *partial, // optional partial for context |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5543 funccall_T *funccal, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5544 typval_T *rettv) // return value |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5545 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5546 ectx_T ectx; // execution context |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5547 int argc = argc_arg; |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5548 int partial_argc = partial == NULL |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5549 || (flags & DEF_USE_PT_ARGV) == 0 |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5550 ? 0 : partial->pt_argc; |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5551 int total_argc = argc + partial_argc; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5552 typval_T *tv; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5553 int idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5554 int ret = FAIL; |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5555 int defcount = ufunc->uf_args.ga_len - total_argc; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5556 sctx_T save_current_sctx = current_sctx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5557 int did_emsg_before = did_emsg_cumul + did_emsg; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5558 int save_suppress_errthrow = suppress_errthrow; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5559 msglist_T **saved_msg_list = NULL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5560 msglist_T *private_msg_list = NULL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5561 int save_emsg_silent_def = emsg_silent_def; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5562 int save_did_emsg_def = did_emsg_def; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5563 int orig_funcdepth; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5564 int orig_nesting_level = ex_nesting_level; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5565 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5566 // Get pointer to item in the stack. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5567 #undef STACK_TV |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5568 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5569 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5570 // Get pointer to item at the bottom of the stack, -1 is the bottom. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5571 #undef STACK_TV_BOT |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5572 #define STACK_TV_BOT(idx) (((typval_T *)ectx.ec_stack.ga_data) + ectx.ec_stack.ga_len + idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5573 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5574 // Get pointer to a local variable on the stack. Negative for arguments. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5575 #undef STACK_TV_VAR |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5576 #define STACK_TV_VAR(idx) (((typval_T *)ectx.ec_stack.ga_data) + ectx.ec_frame_idx + STACK_FRAME_SIZE + idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5577 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5578 if (ufunc->uf_def_status == UF_NOT_COMPILED |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5579 || ufunc->uf_def_status == UF_COMPILE_ERROR |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
5580 || (func_needs_compiling(ufunc, get_compile_type(ufunc)) |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
5581 && compile_def_function(ufunc, FALSE, |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
5582 get_compile_type(ufunc), NULL) == FAIL)) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5583 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5584 if (did_emsg_cumul + did_emsg == did_emsg_before) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5585 semsg(_(e_function_is_not_compiled_str), |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5586 printable_func_name(ufunc)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5587 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5588 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5589 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5590 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5591 // Check the function was really compiled. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5592 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5593 + ufunc->uf_dfunc_idx; |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5594 if (dfunc->df_ufunc == NULL) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5595 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5596 semsg(_(e_function_was_deleted_str), printable_func_name(ufunc)); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5597 return FAIL; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5598 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5599 if (INSTRUCTIONS(dfunc) == NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5600 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5601 iemsg("using call_def_function() on not compiled function"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5602 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5603 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5604 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5605 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5606 // If depth of calling is getting too high, don't execute the function. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5607 orig_funcdepth = funcdepth_get(); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5608 if (funcdepth_increment() == FAIL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5609 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5610 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5611 CLEAR_FIELD(ectx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5612 ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5613 ga_init2(&ectx.ec_stack, sizeof(typval_T), 500); |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
5614 if (GA_GROW_FAILS(&ectx.ec_stack, 20)) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5615 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5616 funcdepth_decrement(); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5617 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5618 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5619 ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5620 ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5621 ectx.ec_did_emsg_before = did_emsg_before; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5622 ++ex_nesting_level; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5623 |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5624 idx = total_argc - ufunc->uf_args.ga_len; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5625 if (idx > 0 && ufunc->uf_va_name == NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5626 { |
29322
ac102d0fb50f
patch 9.0.0004: plural messages not translated properly
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
5627 semsg(NGETTEXT(e_one_argument_too_many, e_nr_arguments_too_many, |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5628 idx), idx); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5629 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5630 } |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5631 idx = total_argc - ufunc->uf_args.ga_len + ufunc->uf_def_args.ga_len; |
24810
30095f94d081
patch 8.2.2943: Vim9: check for argument count ignores default values
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
5632 if (idx < 0) |
24808
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
5633 { |
29322
ac102d0fb50f
patch 9.0.0004: plural messages not translated properly
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
5634 semsg(NGETTEXT(e_one_argument_too_few, e_nr_arguments_too_few, |
30126
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30124
diff
changeset
|
5635 -idx), -idx); |
24808
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
5636 goto failed_early; |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
5637 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5638 |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5639 // Put values from the partial and arguments on the stack, but no more than |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5640 // what the function expects. A lambda can be called with more arguments |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5641 // than it uses. |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5642 for (idx = 0; idx < total_argc |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5643 && (ufunc->uf_va_name != NULL || idx < ufunc->uf_args.ga_len); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5644 ++idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5645 { |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5646 int argv_idx = idx - partial_argc; |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5647 |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5648 tv = idx < partial_argc ? partial->pt_argv + idx : argv + argv_idx; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5649 if (idx >= ufunc->uf_args.ga_len - ufunc->uf_def_args.ga_len |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5650 && tv->v_type == VAR_SPECIAL |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5651 && tv->vval.v_number == VVAL_NONE) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5652 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5653 // Use the default value. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5654 STACK_TV_BOT(0)->v_type = VAR_UNKNOWN; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5655 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5656 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5657 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5658 if (ufunc->uf_arg_types != NULL && idx < ufunc->uf_args.ga_len |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5659 && check_typval_arg_type( |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5660 ufunc->uf_arg_types[idx], tv, |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5661 NULL, argv_idx + 1) == FAIL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5662 goto failed_early; |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
5663 copy_tv(tv, STACK_TV_BOT(0)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5664 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5665 ++ectx.ec_stack.ga_len; |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
5666 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5667 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5668 // Turn varargs into a list. Empty list if no args. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5669 if (ufunc->uf_va_name != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5670 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5671 int vararg_count = argc - ufunc->uf_args.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5672 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5673 if (vararg_count < 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5674 vararg_count = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5675 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5676 argc -= vararg_count; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5677 if (exe_newlist(vararg_count, &ectx) == FAIL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5678 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5679 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5680 // Check the type of the list items. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5681 tv = STACK_TV_BOT(-1); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5682 if (ufunc->uf_va_type != NULL |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5683 && ufunc->uf_va_type != &t_list_any |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5684 && ufunc->uf_va_type->tt_member != &t_any |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5685 && tv->vval.v_list != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5686 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5687 type_T *expected = ufunc->uf_va_type->tt_member; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5688 listitem_T *li = tv->vval.v_list->lv_first; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5689 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5690 for (idx = 0; idx < vararg_count; ++idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5691 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5692 if (check_typval_arg_type(expected, &li->li_tv, |
25326
cfbf40f749b0
patch 8.2.3200: Vim9: hard to guess where a type error is given
Bram Moolenaar <Bram@vim.org>
parents:
25324
diff
changeset
|
5693 NULL, argc + idx + 1) == FAIL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5694 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5695 li = li->li_next; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5696 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5697 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5698 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5699 if (defcount > 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5700 // Move varargs list to below missing default arguments. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5701 *STACK_TV_BOT(defcount - 1) = *STACK_TV_BOT(-1); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5702 --ectx.ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5703 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5704 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5705 // Make space for omitted arguments, will store default value below. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5706 // Any varargs list goes after them. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5707 if (defcount > 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5708 for (idx = 0; idx < defcount; ++idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5709 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5710 STACK_TV_BOT(0)->v_type = VAR_UNKNOWN; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5711 ++ectx.ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5712 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5713 if (ufunc->uf_va_name != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5714 ++ectx.ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5715 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5716 // Frame pointer points to just after arguments. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5717 ectx.ec_frame_idx = ectx.ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5718 ectx.ec_initial_frame_idx = ectx.ec_frame_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5719 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5720 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5721 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5722 + ufunc->uf_dfunc_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5723 ufunc_T *base_ufunc = dfunc->df_ufunc; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5724 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5725 // "uf_partial" is on the ufunc that "df_ufunc" points to, as is done |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
5726 // by copy_lambda_to_global_func(). |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5727 if (partial != NULL || base_ufunc->uf_partial != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5728 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5729 ectx.ec_outer_ref = ALLOC_CLEAR_ONE(outer_ref_T); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5730 if (ectx.ec_outer_ref == NULL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5731 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5732 if (partial != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5733 { |
27591
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
5734 outer_T *outer = get_pt_outer(partial); |
30423
221cca379bd5
patch 9.0.0547: looping over empty out_loop[] entries
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
5735 |
221cca379bd5
patch 9.0.0547: looping over empty out_loop[] entries
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
5736 if (outer->out_stack == NULL && outer->out_loop_size == 0) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5737 { |
30423
221cca379bd5
patch 9.0.0547: looping over empty out_loop[] entries
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
5738 // no stack was set |
27565
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
5739 if (current_ectx != NULL) |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
5740 { |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
5741 if (current_ectx->ec_outer_ref != NULL |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
5742 && current_ectx->ec_outer_ref->or_outer != NULL) |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
5743 ectx.ec_outer_ref->or_outer = |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5744 current_ectx->ec_outer_ref->or_outer; |
27565
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
5745 } |
30299
5c181bb6c855
patch 9.0.0485: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30291
diff
changeset
|
5746 // else: should there be an error here? |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5747 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5748 else |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5749 { |
27591
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27585
diff
changeset
|
5750 ectx.ec_outer_ref->or_outer = outer; |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5751 ++partial->pt_refcount; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5752 ectx.ec_outer_ref->or_partial = partial; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5753 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5754 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5755 else |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5756 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5757 ectx.ec_outer_ref->or_outer = &base_ufunc->uf_partial->pt_outer; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5758 ++base_ufunc->uf_partial->pt_refcount; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5759 ectx.ec_outer_ref->or_partial = base_ufunc->uf_partial; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5760 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5761 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5762 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5763 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5764 // dummy frame entries |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5765 for (idx = 0; idx < STACK_FRAME_SIZE; ++idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5766 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5767 STACK_TV(ectx.ec_stack.ga_len)->v_type = VAR_UNKNOWN; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5768 ++ectx.ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5769 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5770 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5771 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5772 // Reserve space for local variables and any closure reference count. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5773 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5774 + ufunc->uf_dfunc_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5775 |
26729
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
5776 // Initialize variables to zero. That avoids having to generate |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
5777 // initializing instructions for "var nr: number", "var x: any", etc. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5778 for (idx = 0; idx < dfunc->df_varcount; ++idx) |
26729
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
5779 { |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
5780 STACK_TV_VAR(idx)->v_type = VAR_NUMBER; |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
5781 STACK_TV_VAR(idx)->vval.v_number = 0; |
b969fdb8cd46
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
5782 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5783 ectx.ec_stack.ga_len += dfunc->df_varcount; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5784 if (dfunc->df_has_closure) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5785 { |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5786 // Initialize the variable that counts how many closures were |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5787 // created. This is used in handle_closure_in_use(). |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5788 STACK_TV_VAR(idx)->v_type = VAR_NUMBER; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5789 STACK_TV_VAR(idx)->vval.v_number = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5790 ++ectx.ec_stack.ga_len; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5791 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5792 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5793 ectx.ec_instr = INSTRUCTIONS(dfunc); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5794 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5795 |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5796 // Store the execution context in funccal, used by invoke_all_defer(). |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5797 if (funccal != NULL) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5798 funccal->fc_ectx = &ectx; |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5799 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5800 // Following errors are in the function, not the caller. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5801 // Commands behave like vim9script. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5802 estack_push_ufunc(ufunc, 1); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5803 current_sctx = ufunc->uf_script_ctx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5804 current_sctx.sc_version = SCRIPT_VERSION_VIM9; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5805 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5806 // Use a specific location for storing error messages to be converted to an |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5807 // exception. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5808 saved_msg_list = msg_list; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5809 msg_list = &private_msg_list; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5810 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5811 // Do turn errors into exceptions. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5812 suppress_errthrow = FALSE; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5813 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5814 // Do not delete the function while executing it. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5815 ++ufunc->uf_calls; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5816 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5817 // When ":silent!" was used before calling then we still abort the |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5818 // function. If ":silent!" is used in the function then we don't. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5819 emsg_silent_def = emsg_silent; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5820 did_emsg_def = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5821 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5822 ectx.ec_where.wt_index = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5823 ectx.ec_where.wt_variable = FALSE; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5824 |
30427
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
5825 /* |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
5826 * Execute the instructions until done. |
4198995b9210
patch 9.0.0549: duplicated code in calling a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30423
diff
changeset
|
5827 */ |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5828 ret = exec_instructions(&ectx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5829 if (ret == OK) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5830 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5831 // function finished, get result from the stack. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5832 if (ufunc->uf_ret_type == &t_void) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5833 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5834 rettv->v_type = VAR_VOID; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5835 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5836 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5837 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5838 tv = STACK_TV_BOT(-1); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5839 *rettv = *tv; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5840 tv->v_type = VAR_UNKNOWN; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5841 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5842 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5843 |
19532
b8f778dda1a1
patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents:
19528
diff
changeset
|
5844 // When failed need to unwind the call stack. |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5845 unwind_def_callstack(&ectx); |
21969
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21933
diff
changeset
|
5846 |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5847 // Deal with any remaining closures, they may be in use somewhere. |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5848 if (ectx.ec_funcrefs.ga_len > 0) |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
5849 { |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5850 handle_closure_in_use(&ectx, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
26644
diff
changeset
|
5851 ga_clear(&ectx.ec_funcrefs); |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
5852 } |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5853 |
21969
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21933
diff
changeset
|
5854 estack_pop(); |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21933
diff
changeset
|
5855 current_sctx = save_current_sctx; |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21933
diff
changeset
|
5856 |
26445
568f93dcdc62
patch 8.2.3753: Vim9: function unreferenced while called is never deleted
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
5857 if (--ufunc->uf_calls <= 0 && ufunc->uf_refcount <= 0) |
568f93dcdc62
patch 8.2.3753: Vim9: function unreferenced while called is never deleted
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
5858 // Function was unreferenced while being used, free it now. |
568f93dcdc62
patch 8.2.3753: Vim9: function unreferenced while called is never deleted
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
5859 func_clear_free(ufunc, FALSE); |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
5860 |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5861 if (*msg_list != NULL && saved_msg_list != NULL) |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5862 { |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5863 msglist_T **plist = saved_msg_list; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5864 |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5865 // Append entries from the current msg_list (uncaught exceptions) to |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5866 // the saved msg_list. |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5867 while (*plist != NULL) |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5868 plist = &(*plist)->next; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5869 |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5870 *plist = *msg_list; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5871 } |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5872 msg_list = saved_msg_list; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5873 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5874 if (ectx.ec_funclocal.floc_restore_cmdmod) |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5875 { |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5876 cmdmod.cmod_filter_regmatch.regprog = NULL; |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5877 undo_cmdmod(&cmdmod); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5878 cmdmod = ectx.ec_funclocal.floc_save_cmdmod; |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5879 } |
23102
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
5880 emsg_silent_def = save_emsg_silent_def; |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
5881 did_emsg_def += save_did_emsg_def; |
22691
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
5882 |
20021
4895e5cf1746
patch 8.2.0566: Vim9: variable can be used uninitialized
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
5883 failed_early: |
28343
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28309
diff
changeset
|
5884 // Free all arguments and local variables. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5885 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx) |
30564
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
5886 { |
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
5887 tv = STACK_TV(idx); |
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
5888 if (tv->v_type != VAR_NUMBER && tv->v_type != VAR_UNKNOWN) |
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
5889 clear_tv(tv); |
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
5890 } |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5891 ex_nesting_level = orig_nesting_level; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
5892 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5893 vim_free(ectx.ec_stack.ga_data); |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
5894 vim_free(ectx.ec_trystack.ga_data); |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5895 if (ectx.ec_outer_ref != NULL) |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
5896 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5897 if (ectx.ec_outer_ref->or_outer_allocated) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5898 vim_free(ectx.ec_outer_ref->or_outer); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5899 partial_unref(ectx.ec_outer_ref->or_partial); |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5900 vim_free(ectx.ec_outer_ref); |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
5901 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
5902 |
22310
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
5903 // Not sure if this is necessary. |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
5904 suppress_errthrow = save_suppress_errthrow; |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
5905 |
25260
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
5906 if (ret != OK && did_emsg_cumul + did_emsg == did_emsg_before |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
5907 && !need_rethrow) |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
5908 semsg(_(e_unknown_error_while_executing_str), |
21401
aa7675a4a0cd
patch 8.2.1251: Vim9: warning for pointer usage, test failure undetected
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
5909 printable_func_name(ufunc)); |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
5910 funcdepth_restore(orig_funcdepth); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5911 return ret; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5912 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5913 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5914 /* |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5915 * Called when a def function has finished (possibly failed). |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5916 * Invoke all the function returns to clean up and invoke deferred functions, |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5917 * except the toplevel one. |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5918 */ |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5919 void |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5920 unwind_def_callstack(ectx_T *ectx) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5921 { |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5922 while (ectx->ec_frame_idx != ectx->ec_initial_frame_idx) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5923 func_return(ectx); |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5924 } |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5925 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5926 /* |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5927 * Invoke any deffered functions for the top function in "ectx". |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5928 */ |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5929 void |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5930 may_invoke_defer_funcs(ectx_T *ectx) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5931 { |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5932 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + ectx->ec_dfunc_idx; |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5933 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5934 if (dfunc->df_defer_var_idx > 0) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5935 invoke_defer_funcs(ectx); |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5936 } |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5937 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30092
diff
changeset
|
5938 /* |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5939 * Return loopvarinfo in a printable form in allocated memory. |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5940 */ |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5941 static char_u * |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5942 printable_loopvarinfo(loopvarinfo_T *lvi) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5943 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5944 garray_T ga; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5945 int depth; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5946 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5947 ga_init2(&ga, 1, 100); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5948 for (depth = 0; depth < lvi->lvi_depth; ++depth) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5949 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5950 if (ga_grow(&ga, 50) == FAIL) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5951 break; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5952 if (lvi->lvi_loop[depth].var_idx == 0) |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30333
diff
changeset
|
5953 STRCPY((char *)ga.ga_data + ga.ga_len, " -"); |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5954 else |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30333
diff
changeset
|
5955 vim_snprintf((char *)ga.ga_data + ga.ga_len, 50, " $%d-$%d", |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5956 lvi->lvi_loop[depth].var_idx, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5957 lvi->lvi_loop[depth].var_idx |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5958 + lvi->lvi_loop[depth].var_count - 1); |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30333
diff
changeset
|
5959 ga.ga_len = (int)STRLEN(ga.ga_data); |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5960 } |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5961 return ga.ga_data; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5962 } |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5963 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
5964 /* |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5965 * List instructions "instr" up to "instr_count" or until ISN_FINISH. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5966 * "ufunc" has the source lines, NULL for the instructions of ISN_SUBSTITUTE. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5967 * "pfx" is prefixed to every line. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5968 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5969 static void |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5970 list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5971 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5972 int line_idx = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5973 int prev_current = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5974 int current; |
24504
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5975 int def_arg_idx = 0; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5976 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5977 for (current = 0; current < instr_count; ++current) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5978 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5979 isn_T *iptr = &instr[current]; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5980 char *line; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5981 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5982 if (ufunc != NULL) |
24504
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5983 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5984 while (line_idx < iptr->isn_lnum |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5985 && line_idx < ufunc->uf_lines.ga_len) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5986 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5987 if (current > prev_current) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5988 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5989 msg_puts("\n\n"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5990 prev_current = current; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5991 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5992 line = ((char **)ufunc->uf_lines.ga_data)[line_idx++]; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5993 if (line != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5994 msg(line); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5995 } |
24504
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5996 if (iptr->isn_type == ISN_JUMP_IF_ARG_SET) |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5997 { |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5998 int first_def_arg = ufunc->uf_args.ga_len |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5999 - ufunc->uf_def_args.ga_len; |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6000 |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6001 if (def_arg_idx > 0) |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6002 msg_puts("\n\n"); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6003 msg_start(); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6004 msg_puts(" "); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6005 msg_puts(((char **)(ufunc->uf_args.ga_data))[ |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6006 first_def_arg + def_arg_idx]); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6007 msg_puts(" = "); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6008 msg_puts(((char **)(ufunc->uf_def_args.ga_data))[def_arg_idx++]); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6009 msg_clr_eos(); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6010 msg_end(); |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6011 } |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
6012 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6013 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6014 switch (iptr->isn_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6015 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6016 case ISN_EXEC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6017 smsg("%s%4d EXEC %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6018 break; |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
6019 case ISN_EXEC_SPLIT: |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
6020 smsg("%s%4d EXEC_SPLIT %s", pfx, current, iptr->isn_arg.string); |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
6021 break; |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
6022 case ISN_EXECRANGE: |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
6023 smsg("%s%4d EXECRANGE %s", pfx, current, iptr->isn_arg.string); |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
6024 break; |
24645
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
6025 case ISN_LEGACY_EVAL: |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
6026 smsg("%s%4d EVAL legacy %s", pfx, current, |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
6027 iptr->isn_arg.string); |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
6028 break; |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6029 case ISN_REDIRSTART: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6030 smsg("%s%4d REDIR", pfx, current); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6031 break; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6032 case ISN_REDIREND: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6033 smsg("%s%4d REDIR END%s", pfx, current, |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6034 iptr->isn_arg.number ? " append" : ""); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
6035 break; |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6036 case ISN_CEXPR_AUCMD: |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
6037 #ifdef FEAT_QUICKFIX |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6038 smsg("%s%4d CEXPR pre %s", pfx, current, |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6039 cexpr_get_auname(iptr->isn_arg.number)); |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
6040 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6041 break; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6042 case ISN_CEXPR_CORE: |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
6043 #ifdef FEAT_QUICKFIX |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6044 { |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6045 cexprref_T *cer = iptr->isn_arg.cexpr.cexpr_ref; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6046 |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6047 smsg("%s%4d CEXPR core %s%s \"%s\"", pfx, current, |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6048 cexpr_get_auname(cer->cer_cmdidx), |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6049 cer->cer_forceit ? "!" : "", |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6050 cer->cer_cmdline); |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6051 } |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
6052 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
6053 break; |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
6054 case ISN_INSTR: |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6055 smsg("%s%4d INSTR", pfx, current); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6056 list_instructions(" ", iptr->isn_arg.instr, INT_MAX, NULL); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6057 msg(" -------------"); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6058 break; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6059 case ISN_SOURCE: |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
6060 { |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6061 scriptitem_T *si = SCRIPT_ITEM(iptr->isn_arg.number); |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6062 |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6063 smsg("%s%4d SOURCE %s", pfx, current, si->sn_name); |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
6064 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
6065 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6066 case ISN_SUBSTITUTE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6067 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6068 subs_T *subs = &iptr->isn_arg.subs; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6069 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6070 smsg("%s%4d SUBSTITUTE %s", pfx, current, subs->subs_cmd); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6071 list_instructions(" ", subs->subs_instr, INT_MAX, NULL); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6072 msg(" -------------"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6073 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6074 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6075 case ISN_EXECCONCAT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6076 smsg("%s%4d EXECCONCAT %lld", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6077 (varnumber_T)iptr->isn_arg.number); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6078 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6079 case ISN_ECHO: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6080 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6081 echo_T *echo = &iptr->isn_arg.echo; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6082 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6083 smsg("%s%4d %s %d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6084 echo->echo_with_white ? "ECHO" : "ECHON", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6085 echo->echo_count); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6086 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6087 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6088 case ISN_EXECUTE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6089 smsg("%s%4d EXECUTE %lld", pfx, current, |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6090 (varnumber_T)(iptr->isn_arg.number)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6091 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6092 case ISN_ECHOMSG: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6093 smsg("%s%4d ECHOMSG %lld", pfx, current, |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6094 (varnumber_T)(iptr->isn_arg.number)); |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6095 break; |
30025
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
6096 case ISN_ECHOWINDOW: |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
6097 smsg("%s%4d ECHOWINDOW %lld", pfx, current, |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
6098 (varnumber_T)(iptr->isn_arg.number)); |
d269dd3cd31d
patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
29429
diff
changeset
|
6099 break; |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6100 case ISN_ECHOCONSOLE: |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6101 smsg("%s%4d ECHOCONSOLE %lld", pfx, current, |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6102 (varnumber_T)(iptr->isn_arg.number)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6103 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6104 case ISN_ECHOERR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6105 smsg("%s%4d ECHOERR %lld", pfx, current, |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
6106 (varnumber_T)(iptr->isn_arg.number)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6107 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6108 case ISN_LOAD: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6109 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6110 if (iptr->isn_arg.number < 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6111 smsg("%s%4d LOAD arg[%lld]", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6112 (varnumber_T)(iptr->isn_arg.number |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6113 + STACK_FRAME_SIZE)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6114 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6115 smsg("%s%4d LOAD $%lld", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6116 (varnumber_T)(iptr->isn_arg.number)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6117 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6118 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6119 case ISN_LOADOUTER: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6120 { |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6121 isn_outer_T *outer = &iptr->isn_arg.outer; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6122 |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6123 if (outer->outer_idx < 0) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6124 smsg("%s%4d LOADOUTER level %d arg[%d]", pfx, current, |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6125 outer->outer_depth, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6126 outer->outer_idx + STACK_FRAME_SIZE); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6127 else if (outer->outer_depth < 0) |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6128 smsg("%s%4d LOADOUTER $%d in loop level %d", |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6129 pfx, current, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6130 outer->outer_idx, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6131 -outer->outer_depth); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6132 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6133 smsg("%s%4d LOADOUTER level %d $%d", pfx, current, |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6134 outer->outer_depth, |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6135 outer->outer_idx); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6136 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6137 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6138 case ISN_LOADV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6139 smsg("%s%4d LOADV v:%s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6140 get_vim_var_name(iptr->isn_arg.number)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6141 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6142 case ISN_LOADSCRIPT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6143 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6144 scriptref_T *sref = iptr->isn_arg.script.scriptref; |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6145 scriptitem_T *si = SCRIPT_ITEM(sref->sref_sid); |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6146 svar_T *sv; |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6147 |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6148 sv = get_script_svar(sref, -1); |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6149 if (sv == NULL) |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6150 smsg("%s%4d LOADSCRIPT [deleted] from %s", |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6151 pfx, current, si->sn_name); |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6152 else |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6153 smsg("%s%4d LOADSCRIPT %s-%d from %s", pfx, current, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6154 sv->sv_name, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6155 sref->sref_idx, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6156 si->sn_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6157 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6158 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6159 case ISN_LOADS: |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6160 case ISN_LOADEXPORT: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6161 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6162 scriptitem_T *si = SCRIPT_ITEM( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6163 iptr->isn_arg.loadstore.ls_sid); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6164 |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6165 smsg("%s%4d %s s:%s from %s", pfx, current, |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6166 iptr->isn_type == ISN_LOADS ? "LOADS" |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6167 : "LOADEXPORT", |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6168 iptr->isn_arg.loadstore.ls_name, si->sn_name); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6169 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6170 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6171 case ISN_LOADAUTO: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6172 smsg("%s%4d LOADAUTO %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6173 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6174 case ISN_LOADG: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6175 smsg("%s%4d LOADG g:%s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6176 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6177 case ISN_LOADB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6178 smsg("%s%4d LOADB b:%s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6179 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6180 case ISN_LOADW: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6181 smsg("%s%4d LOADW w:%s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6182 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6183 case ISN_LOADT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6184 smsg("%s%4d LOADT t:%s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6185 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6186 case ISN_LOADGDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6187 smsg("%s%4d LOAD g:", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6188 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6189 case ISN_LOADBDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6190 smsg("%s%4d LOAD b:", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6191 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6192 case ISN_LOADWDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6193 smsg("%s%4d LOAD w:", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6194 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6195 case ISN_LOADTDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6196 smsg("%s%4d LOAD t:", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6197 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6198 case ISN_LOADOPT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6199 smsg("%s%4d LOADOPT %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6200 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6201 case ISN_LOADENV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6202 smsg("%s%4d LOADENV %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6203 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6204 case ISN_LOADREG: |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6205 smsg("%s%4d LOADREG @%c", pfx, current, |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6206 (int)(iptr->isn_arg.number)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6207 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6208 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6209 case ISN_STORE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6210 if (iptr->isn_arg.number < 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6211 smsg("%s%4d STORE arg[%lld]", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6212 iptr->isn_arg.number + STACK_FRAME_SIZE); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6213 else |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6214 smsg("%s%4d STORE $%lld", pfx, current, |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6215 iptr->isn_arg.number); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6216 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6217 case ISN_STOREOUTER: |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6218 { |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6219 isn_outer_T *outer = &iptr->isn_arg.outer; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6220 |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6221 if (outer->outer_depth == OUTER_LOOP_DEPTH) |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6222 smsg("%s%4d STOREOUTER level 1 $%d in loop", |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6223 pfx, current, outer->outer_idx); |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6224 else |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6225 smsg("%s%4d STOREOUTER level %d $%d", pfx, current, |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6226 outer->outer_depth, outer->outer_idx); |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6227 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6228 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6229 case ISN_STOREV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6230 smsg("%s%4d STOREV v:%s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6231 get_vim_var_name(iptr->isn_arg.number)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6232 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6233 case ISN_STOREAUTO: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6234 smsg("%s%4d STOREAUTO %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6235 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6236 case ISN_STOREG: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6237 smsg("%s%4d STOREG %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6238 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6239 case ISN_STOREB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6240 smsg("%s%4d STOREB %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6241 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6242 case ISN_STOREW: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6243 smsg("%s%4d STOREW %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6244 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6245 case ISN_STORET: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6246 smsg("%s%4d STORET %s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6247 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6248 case ISN_STORES: |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6249 case ISN_STOREEXPORT: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6250 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6251 scriptitem_T *si = SCRIPT_ITEM( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6252 iptr->isn_arg.loadstore.ls_sid); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6253 |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6254 smsg("%s%4d %s %s in %s", pfx, current, |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6255 iptr->isn_type == ISN_STORES |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28233
diff
changeset
|
6256 ? "STORES" : "STOREEXPORT", |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6257 iptr->isn_arg.loadstore.ls_name, si->sn_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6258 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6259 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6260 case ISN_STORESCRIPT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6261 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6262 scriptref_T *sref = iptr->isn_arg.script.scriptref; |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6263 scriptitem_T *si = SCRIPT_ITEM(sref->sref_sid); |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6264 svar_T *sv; |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6265 |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6266 sv = get_script_svar(sref, -1); |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6267 if (sv == NULL) |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6268 smsg("%s%4d STORESCRIPT [deleted] in %s", |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6269 pfx, current, si->sn_name); |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6270 else |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6271 smsg("%s%4d STORESCRIPT %s-%d in %s", pfx, current, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6272 sv->sv_name, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6273 sref->sref_idx, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6274 si->sn_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6275 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6276 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6277 case ISN_STOREOPT: |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
6278 case ISN_STOREFUNCOPT: |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
6279 smsg("%s%4d %s &%s", pfx, current, |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
6280 iptr->isn_type == ISN_STOREOPT ? "STOREOPT" : "STOREFUNCOPT", |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6281 iptr->isn_arg.storeopt.so_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6282 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6283 case ISN_STOREENV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6284 smsg("%s%4d STOREENV $%s", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6285 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6286 case ISN_STOREREG: |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6287 smsg("%s%4d STOREREG @%c", pfx, current, |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6288 (int)iptr->isn_arg.number); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6289 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6290 case ISN_STORENR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6291 smsg("%s%4d STORE %lld in $%d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6292 iptr->isn_arg.storenr.stnr_val, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6293 iptr->isn_arg.storenr.stnr_idx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6294 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6295 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6296 case ISN_STOREINDEX: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6297 smsg("%s%4d STOREINDEX %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6298 vartype_name(iptr->isn_arg.vartype)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6299 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6300 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6301 case ISN_STORERANGE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6302 smsg("%s%4d STORERANGE", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6303 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6304 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6305 // constants |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6306 case ISN_PUSHNR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6307 smsg("%s%4d PUSHNR %lld", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6308 (varnumber_T)(iptr->isn_arg.number)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6309 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6310 case ISN_PUSHBOOL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6311 case ISN_PUSHSPEC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6312 smsg("%s%4d PUSH %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6313 get_var_special_name(iptr->isn_arg.number)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6314 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6315 case ISN_PUSHF: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6316 smsg("%s%4d PUSHF %g", pfx, current, iptr->isn_arg.fnumber); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6317 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6318 case ISN_PUSHS: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6319 smsg("%s%4d PUSHS \"%s\"", pfx, current, iptr->isn_arg.string); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6320 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6321 case ISN_PUSHBLOB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6322 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6323 char_u *r; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6324 char_u numbuf[NUMBUFLEN]; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6325 char_u *tofree; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6326 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6327 r = blob2string(iptr->isn_arg.blob, &tofree, numbuf); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6328 smsg("%s%4d PUSHBLOB %s", pfx, current, r); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6329 vim_free(tofree); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6330 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6331 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6332 case ISN_PUSHFUNC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6333 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6334 char *name = (char *)iptr->isn_arg.string; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6335 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6336 smsg("%s%4d PUSHFUNC \"%s\"", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6337 name == NULL ? "[none]" : name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6338 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6339 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6340 case ISN_PUSHCHANNEL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6341 #ifdef FEAT_JOB_CHANNEL |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
6342 smsg("%s%4d PUSHCHANNEL 0", pfx, current); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6343 #endif |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6344 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6345 case ISN_PUSHJOB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6346 #ifdef FEAT_JOB_CHANNEL |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
6347 smsg("%s%4d PUSHJOB \"no process\"", pfx, current); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6348 #endif |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6349 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6350 case ISN_PUSHEXC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6351 smsg("%s%4d PUSH v:exception", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6352 break; |
27376
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
6353 case ISN_AUTOLOAD: |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
6354 smsg("%s%4d AUTOLOAD %s", pfx, current, iptr->isn_arg.string); |
1a6421c5be20
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents:
27340
diff
changeset
|
6355 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6356 case ISN_UNLET: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6357 smsg("%s%4d UNLET%s %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6358 iptr->isn_arg.unlet.ul_forceit ? "!" : "", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6359 iptr->isn_arg.unlet.ul_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6360 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6361 case ISN_UNLETENV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6362 smsg("%s%4d UNLETENV%s $%s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6363 iptr->isn_arg.unlet.ul_forceit ? "!" : "", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6364 iptr->isn_arg.unlet.ul_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6365 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6366 case ISN_UNLETINDEX: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6367 smsg("%s%4d UNLETINDEX", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6368 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6369 case ISN_UNLETRANGE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6370 smsg("%s%4d UNLETRANGE", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6371 break; |
25605
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
6372 case ISN_LOCKUNLOCK: |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
6373 smsg("%s%4d LOCKUNLOCK %s", pfx, current, iptr->isn_arg.string); |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
6374 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6375 case ISN_LOCKCONST: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6376 smsg("%s%4d LOCKCONST", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6377 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6378 case ISN_NEWLIST: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6379 smsg("%s%4d NEWLIST size %lld", pfx, current, |
30564
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
6380 (varnumber_T)(iptr->isn_arg.number)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6381 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6382 case ISN_NEWDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6383 smsg("%s%4d NEWDICT size %lld", pfx, current, |
30564
30025bbc1705
patch 9.0.0617: calling function for reduce() has too much overhead
Bram Moolenaar <Bram@vim.org>
parents:
30427
diff
changeset
|
6384 (varnumber_T)(iptr->isn_arg.number)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6385 break; |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
6386 case ISN_NEWPARTIAL: |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
6387 smsg("%s%4d NEWPARTIAL", pfx, current); |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
6388 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6389 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6390 // function call |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6391 case ISN_BCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6392 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6393 cbfunc_T *cbfunc = &iptr->isn_arg.bfunc; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6394 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6395 smsg("%s%4d BCALL %s(argc %d)", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6396 internal_func_name(cbfunc->cbf_idx), |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6397 cbfunc->cbf_argcount); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6398 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6399 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6400 case ISN_DCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6401 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6402 cdfunc_T *cdfunc = &iptr->isn_arg.dfunc; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6403 dfunc_T *df = ((dfunc_T *)def_functions.ga_data) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6404 + cdfunc->cdf_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6405 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6406 smsg("%s%4d DCALL %s(argc %d)", pfx, current, |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6407 printable_func_name(df->df_ufunc), |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6408 cdfunc->cdf_argcount); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6409 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6410 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6411 case ISN_UCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6412 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6413 cufunc_T *cufunc = &iptr->isn_arg.ufunc; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6414 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6415 smsg("%s%4d UCALL %s(argc %d)", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6416 cufunc->cuf_name, cufunc->cuf_argcount); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6417 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6418 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6419 case ISN_PCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6420 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6421 cpfunc_T *cpfunc = &iptr->isn_arg.pfunc; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6422 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6423 smsg("%s%4d PCALL%s (argc %d)", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6424 cpfunc->cpf_top ? " top" : "", cpfunc->cpf_argcount); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6425 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6426 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6427 case ISN_PCALL_END: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6428 smsg("%s%4d PCALL end", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6429 break; |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
6430 case ISN_DEFER: |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
6431 smsg("%s%4d DEFER %d args", pfx, current, |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
6432 (int)iptr->isn_arg.defer.defer_argcount); |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
30025
diff
changeset
|
6433 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6434 case ISN_RETURN: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6435 smsg("%s%4d RETURN", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6436 break; |
24936
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24932
diff
changeset
|
6437 case ISN_RETURN_VOID: |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24932
diff
changeset
|
6438 smsg("%s%4d RETURN void", pfx, current); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6439 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6440 case ISN_FUNCREF: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6441 { |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6442 funcref_T *funcref = &iptr->isn_arg.funcref; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6443 funcref_extra_T *extra = funcref->fr_extra; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6444 char_u *name; |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6445 |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6446 if (extra == NULL || extra->fre_func_name == NULL) |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
6447 { |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
6448 dfunc_T *df = ((dfunc_T *)def_functions.ga_data) |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
6449 + funcref->fr_dfunc_idx; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
6450 name = df->df_ufunc->uf_name; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
6451 } |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
6452 else |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6453 name = extra->fre_func_name; |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6454 if (extra == NULL || extra->fre_loopvar_info.lvi_depth == 0) |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6455 smsg("%s%4d FUNCREF %s", pfx, current, name); |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6456 else |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6457 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6458 char_u *info = printable_loopvarinfo( |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6459 &extra->fre_loopvar_info); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6460 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6461 smsg("%s%4d FUNCREF %s vars %s", pfx, current, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6462 name, info); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6463 vim_free(info); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6464 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6465 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6466 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6467 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6468 case ISN_NEWFUNC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6469 { |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6470 newfuncarg_T *arg = iptr->isn_arg.newfunc.nf_arg; |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6471 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6472 if (arg->nfa_loopvar_info.lvi_depth == 0) |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6473 smsg("%s%4d NEWFUNC %s %s", pfx, current, |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6474 arg->nfa_lambda, arg->nfa_global); |
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30269
diff
changeset
|
6475 else |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6476 { |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6477 char_u *info = printable_loopvarinfo( |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6478 &arg->nfa_loopvar_info); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6479 |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6480 smsg("%s%4d NEWFUNC %s %s vars %s", pfx, current, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6481 arg->nfa_lambda, arg->nfa_global, info); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6482 vim_free(info); |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6483 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6484 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6485 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6486 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6487 case ISN_DEF: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6488 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6489 char_u *name = iptr->isn_arg.string; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6490 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6491 smsg("%s%4d DEF %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6492 name == NULL ? (char_u *)"" : name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6493 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6494 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6495 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6496 case ISN_JUMP: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6497 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6498 char *when = "?"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6499 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6500 switch (iptr->isn_arg.jump.jump_when) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6501 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6502 case JUMP_ALWAYS: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6503 when = "JUMP"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6504 break; |
25814
dd4e86558836
patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
6505 case JUMP_NEVER: |
dd4e86558836
patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
6506 iemsg("JUMP_NEVER should not be used"); |
dd4e86558836
patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
6507 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6508 case JUMP_AND_KEEP_IF_TRUE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6509 when = "JUMP_AND_KEEP_IF_TRUE"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6510 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6511 case JUMP_IF_FALSE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6512 when = "JUMP_IF_FALSE"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6513 break; |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6514 case JUMP_WHILE_FALSE: |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6515 when = "JUMP_WHILE_FALSE"; // unused |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6516 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6517 case JUMP_IF_COND_FALSE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6518 when = "JUMP_IF_COND_FALSE"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6519 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6520 case JUMP_IF_COND_TRUE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6521 when = "JUMP_IF_COND_TRUE"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6522 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6523 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6524 smsg("%s%4d %s -> %d", pfx, current, when, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6525 iptr->isn_arg.jump.jump_where); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6526 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6527 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6528 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6529 case ISN_JUMP_IF_ARG_SET: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6530 smsg("%s%4d JUMP_IF_ARG_SET arg[%d] -> %d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6531 iptr->isn_arg.jumparg.jump_arg_off + STACK_FRAME_SIZE, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6532 iptr->isn_arg.jump.jump_where); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6533 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6534 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6535 case ISN_FOR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6536 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6537 forloop_T *forloop = &iptr->isn_arg.forloop; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6538 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6539 smsg("%s%4d FOR $%d -> %d", pfx, current, |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6540 forloop->for_loop_idx, forloop->for_end); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6541 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6542 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6543 |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6544 case ISN_ENDLOOP: |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6545 { |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6546 endloop_T *endloop = &iptr->isn_arg.endloop; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6547 |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6548 smsg("%s%4d ENDLOOP ref $%d save $%d-$%d depth %d", |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6549 pfx, current, |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6550 endloop->end_funcref_idx, |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6551 endloop->end_var_idx, |
30333
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6552 endloop->end_var_idx + endloop->end_var_count - 1, |
fc0830246f49
patch 9.0.0502: a closure in a nested loop in a :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
30327
diff
changeset
|
6553 endloop->end_depth); |
30269
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6554 } |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6555 break; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6556 |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6557 case ISN_WHILE: |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6558 { |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6559 whileloop_T *whileloop = &iptr->isn_arg.whileloop; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6560 |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6561 smsg("%s%4d WHILE $%d -> %d", pfx, current, |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6562 whileloop->while_funcref_idx, |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6563 whileloop->while_end); |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6564 } |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6565 break; |
42a6345b91fd
patch 9.0.0470: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
6566 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6567 case ISN_TRY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6568 { |
26672
3516017e5f54
patch 8.2.3865: Vim9: compiler complains about using "try" as a struct member
Bram Moolenaar <Bram@vim.org>
parents:
26662
diff
changeset
|
6569 try_T *try = &iptr->isn_arg.tryref; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6570 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6571 if (try->try_ref->try_finally == 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6572 smsg("%s%4d TRY catch -> %d, endtry -> %d", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6573 pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6574 try->try_ref->try_catch, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6575 try->try_ref->try_endtry); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6576 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6577 smsg("%s%4d TRY catch -> %d, finally -> %d, endtry -> %d", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6578 pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6579 try->try_ref->try_catch, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6580 try->try_ref->try_finally, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6581 try->try_ref->try_endtry); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6582 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6583 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6584 case ISN_CATCH: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6585 smsg("%s%4d CATCH", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6586 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6587 case ISN_TRYCONT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6588 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6589 trycont_T *trycont = &iptr->isn_arg.trycont; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6590 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6591 smsg("%s%4d TRY-CONTINUE %d level%s -> %d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6592 trycont->tct_levels, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6593 trycont->tct_levels == 1 ? "" : "s", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6594 trycont->tct_where); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6595 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6596 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6597 case ISN_FINALLY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6598 smsg("%s%4d FINALLY", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6599 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6600 case ISN_ENDTRY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6601 smsg("%s%4d ENDTRY", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6602 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6603 case ISN_THROW: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6604 smsg("%s%4d THROW", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6605 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6606 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6607 // expression operations on number |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6608 case ISN_OPNR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6609 case ISN_OPFLOAT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6610 case ISN_OPANY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6611 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6612 char *what; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6613 char *ins; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6614 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6615 switch (iptr->isn_arg.op.op_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6616 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6617 case EXPR_MULT: what = "*"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6618 case EXPR_DIV: what = "/"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6619 case EXPR_REM: what = "%"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6620 case EXPR_SUB: what = "-"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6621 case EXPR_ADD: what = "+"; break; |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
6622 case EXPR_LSHIFT: what = "<<"; break; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28946
diff
changeset
|
6623 case EXPR_RSHIFT: what = ">>"; break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6624 default: what = "???"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6625 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6626 switch (iptr->isn_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6627 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6628 case ISN_OPNR: ins = "OPNR"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6629 case ISN_OPFLOAT: ins = "OPFLOAT"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6630 case ISN_OPANY: ins = "OPANY"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6631 default: ins = "???"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6632 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6633 smsg("%s%4d %s %s", pfx, current, ins, what); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6634 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6635 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6636 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6637 case ISN_COMPAREBOOL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6638 case ISN_COMPARESPECIAL: |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
6639 case ISN_COMPARENULL: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6640 case ISN_COMPARENR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6641 case ISN_COMPAREFLOAT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6642 case ISN_COMPARESTRING: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6643 case ISN_COMPAREBLOB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6644 case ISN_COMPARELIST: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6645 case ISN_COMPAREDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6646 case ISN_COMPAREFUNC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6647 case ISN_COMPAREANY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6648 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6649 char *p; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6650 char buf[10]; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6651 char *type; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6652 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6653 switch (iptr->isn_arg.op.op_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6654 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6655 case EXPR_EQUAL: p = "=="; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6656 case EXPR_NEQUAL: p = "!="; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6657 case EXPR_GREATER: p = ">"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6658 case EXPR_GEQUAL: p = ">="; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6659 case EXPR_SMALLER: p = "<"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6660 case EXPR_SEQUAL: p = "<="; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6661 case EXPR_MATCH: p = "=~"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6662 case EXPR_IS: p = "is"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6663 case EXPR_ISNOT: p = "isnot"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6664 case EXPR_NOMATCH: p = "!~"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6665 default: p = "???"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6666 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6667 STRCPY(buf, p); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6668 if (iptr->isn_arg.op.op_ic == TRUE) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6669 strcat(buf, "?"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6670 switch(iptr->isn_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6671 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6672 case ISN_COMPAREBOOL: type = "COMPAREBOOL"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6673 case ISN_COMPARESPECIAL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6674 type = "COMPARESPECIAL"; break; |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
6675 case ISN_COMPARENULL: type = "COMPARENULL"; break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6676 case ISN_COMPARENR: type = "COMPARENR"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6677 case ISN_COMPAREFLOAT: type = "COMPAREFLOAT"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6678 case ISN_COMPARESTRING: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6679 type = "COMPARESTRING"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6680 case ISN_COMPAREBLOB: type = "COMPAREBLOB"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6681 case ISN_COMPARELIST: type = "COMPARELIST"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6682 case ISN_COMPAREDICT: type = "COMPAREDICT"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6683 case ISN_COMPAREFUNC: type = "COMPAREFUNC"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6684 case ISN_COMPAREANY: type = "COMPAREANY"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6685 default: type = "???"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6686 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6687 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6688 smsg("%s%4d %s %s", pfx, current, type, buf); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6689 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6690 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6691 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6692 case ISN_ADDLIST: smsg("%s%4d ADDLIST", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6693 case ISN_ADDBLOB: smsg("%s%4d ADDBLOB", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6694 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6695 // expression operations |
28598
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
6696 case ISN_CONCAT: |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
6697 smsg("%s%4d CONCAT size %lld", pfx, current, |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
6698 (varnumber_T)(iptr->isn_arg.number)); |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28459
diff
changeset
|
6699 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6700 case ISN_STRINDEX: smsg("%s%4d STRINDEX", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6701 case ISN_STRSLICE: smsg("%s%4d STRSLICE", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6702 case ISN_BLOBINDEX: smsg("%s%4d BLOBINDEX", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6703 case ISN_BLOBSLICE: smsg("%s%4d BLOBSLICE", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6704 case ISN_LISTAPPEND: smsg("%s%4d LISTAPPEND", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6705 case ISN_BLOBAPPEND: smsg("%s%4d BLOBAPPEND", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6706 case ISN_LISTINDEX: smsg("%s%4d LISTINDEX", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6707 case ISN_LISTSLICE: smsg("%s%4d LISTSLICE", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6708 case ISN_ANYINDEX: smsg("%s%4d ANYINDEX", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6709 case ISN_ANYSLICE: smsg("%s%4d ANYSLICE", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6710 case ISN_SLICE: smsg("%s%4d SLICE %lld", |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
6711 pfx, current, iptr->isn_arg.number); break; |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
6712 case ISN_GETITEM: smsg("%s%4d ITEM %lld%s", pfx, current, |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
6713 iptr->isn_arg.getitem.gi_index, |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
6714 iptr->isn_arg.getitem.gi_with_op ? |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24980
diff
changeset
|
6715 " with op" : ""); break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6716 case ISN_MEMBER: smsg("%s%4d MEMBER", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6717 case ISN_STRINGMEMBER: smsg("%s%4d MEMBER %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6718 iptr->isn_arg.string); break; |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
6719 case ISN_CLEARDICT: smsg("%s%4d CLEARDICT", pfx, current); break; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
6720 case ISN_USEDICT: smsg("%s%4d USEDICT", pfx, current); break; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
6721 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6722 case ISN_NEGATENR: smsg("%s%4d NEGATENR", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6723 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6724 case ISN_CHECKTYPE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6725 { |
28901
11609f025219
patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
6726 checktype_T *ct = &iptr->isn_arg.type; |
11609f025219
patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
6727 char *tofree; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6728 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6729 if (ct->ct_arg_idx == 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6730 smsg("%s%4d CHECKTYPE %s stack[%d]", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6731 type_name(ct->ct_type, &tofree), |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6732 (int)ct->ct_off); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6733 else |
28901
11609f025219
patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
6734 smsg("%s%4d CHECKTYPE %s stack[%d] %s %d", |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
6735 pfx, current, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6736 type_name(ct->ct_type, &tofree), |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6737 (int)ct->ct_off, |
28901
11609f025219
patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
6738 ct->ct_is_var ? "var": "arg", |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6739 (int)ct->ct_arg_idx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6740 vim_free(tofree); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6741 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6742 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6743 case ISN_CHECKLEN: smsg("%s%4d CHECKLEN %s%d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6744 iptr->isn_arg.checklen.cl_more_OK ? ">= " : "", |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6745 iptr->isn_arg.checklen.cl_min_len); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6746 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6747 case ISN_SETTYPE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6748 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6749 char *tofree; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6750 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6751 smsg("%s%4d SETTYPE %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6752 type_name(iptr->isn_arg.type.ct_type, &tofree)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6753 vim_free(tofree); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6754 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6755 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6756 case ISN_COND2BOOL: smsg("%s%4d COND2BOOL", pfx, current); break; |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6757 case ISN_2BOOL: if (iptr->isn_arg.tobool.invert) |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6758 smsg("%s%4d INVERT %d (!val)", pfx, current, |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6759 iptr->isn_arg.tobool.offset); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6760 else |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6761 smsg("%s%4d 2BOOL %d (!!val)", pfx, current, |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6762 iptr->isn_arg.tobool.offset); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6763 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6764 case ISN_2STRING: smsg("%s%4d 2STRING stack[%lld]", pfx, current, |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6765 (varnumber_T)(iptr->isn_arg.tostring.offset)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6766 break; |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6767 case ISN_2STRING_ANY: smsg("%s%4d 2STRING_ANY stack[%lld]", |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6768 pfx, current, |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6769 (varnumber_T)(iptr->isn_arg.tostring.offset)); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6770 break; |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6771 case ISN_RANGE: smsg("%s%4d RANGE %s", pfx, current, |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6772 iptr->isn_arg.string); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6773 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6774 case ISN_PUT: |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
6775 if (iptr->isn_arg.put.put_lnum == LNUM_VARIABLE_RANGE_ABOVE) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6776 smsg("%s%4d PUT %c above range", |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6777 pfx, current, iptr->isn_arg.put.put_regname); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6778 else if (iptr->isn_arg.put.put_lnum == LNUM_VARIABLE_RANGE) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6779 smsg("%s%4d PUT %c range", |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
6780 pfx, current, iptr->isn_arg.put.put_regname); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6781 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6782 smsg("%s%4d PUT %c %ld", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6783 iptr->isn_arg.put.put_regname, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6784 (long)iptr->isn_arg.put.put_lnum); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6785 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6786 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6787 case ISN_CMDMOD: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6788 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6789 char_u *buf; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6790 size_t len = produce_cmdmods( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6791 NULL, iptr->isn_arg.cmdmod.cf_cmdmod, FALSE); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6792 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6793 buf = alloc(len + 1); |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
6794 if (likely(buf != NULL)) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6795 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6796 (void)produce_cmdmods( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6797 buf, iptr->isn_arg.cmdmod.cf_cmdmod, FALSE); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6798 smsg("%s%4d CMDMOD %s", pfx, current, buf); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6799 vim_free(buf); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6800 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6801 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6802 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6803 case ISN_CMDMOD_REV: smsg("%s%4d CMDMOD_REV", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6804 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6805 case ISN_PROF_START: |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6806 smsg("%s%4d PROFILE START line %d", pfx, current, |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6807 iptr->isn_lnum); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6808 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6809 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6810 case ISN_PROF_END: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6811 smsg("%s%4d PROFILE END", pfx, current); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6812 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6813 |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6814 case ISN_DEBUG: |
25004
70f55a30f03c
patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
6815 smsg("%s%4d DEBUG line %d-%d varcount %lld", pfx, current, |
70f55a30f03c
patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
6816 iptr->isn_arg.debug.dbg_break_lnum + 1, |
70f55a30f03c
patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
6817 iptr->isn_lnum, |
70f55a30f03c
patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
6818 iptr->isn_arg.debug.dbg_var_names_len); |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6819 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6820 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6821 case ISN_UNPACK: smsg("%s%4d UNPACK %d%s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6822 iptr->isn_arg.unpack.unp_count, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6823 iptr->isn_arg.unpack.unp_semicolon ? " semicolon" : ""); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6824 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6825 case ISN_SHUFFLE: smsg("%s%4d SHUFFLE %d up %d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6826 iptr->isn_arg.shuffle.shfl_item, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6827 iptr->isn_arg.shuffle.shfl_up); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6828 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6829 case ISN_DROP: smsg("%s%4d DROP", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6830 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6831 case ISN_FINISH: // End of list of instructions for ISN_SUBSTITUTE. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6832 return; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6833 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6834 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6835 out_flush(); // output one line at a time |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6836 ui_breakcheck(); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6837 if (got_int) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6838 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6839 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6840 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6841 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6842 /* |
24909
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6843 * Handle command line completion for the :disassemble command. |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6844 */ |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6845 void |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6846 set_context_in_disassemble_cmd(expand_T *xp, char_u *arg) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6847 { |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6848 char_u *p; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6849 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6850 // Default: expand user functions, "debug" and "profile" |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6851 xp->xp_context = EXPAND_DISASSEMBLE; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6852 xp->xp_pattern = arg; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6853 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6854 // first argument already typed: only user function names |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6855 if (*arg != NUL && *(p = skiptowhite(arg)) != NUL) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6856 { |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6857 xp->xp_context = EXPAND_USER_FUNC; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6858 xp->xp_pattern = skipwhite(p); |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6859 } |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6860 } |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6861 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6862 /* |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6863 * Function given to ExpandGeneric() to obtain the list of :disassemble |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6864 * arguments. |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6865 */ |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6866 char_u * |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6867 get_disassemble_argument(expand_T *xp, int idx) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6868 { |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6869 if (idx == 0) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6870 return (char_u *)"debug"; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6871 if (idx == 1) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6872 return (char_u *)"profile"; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6873 return get_user_func_name(xp, idx - 2); |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6874 } |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6875 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
6876 /* |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
6877 * ":disassemble". |
19334
61646c189622
patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19328
diff
changeset
|
6878 * We don't really need this at runtime, but we do have tests that require it, |
61646c189622
patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19328
diff
changeset
|
6879 * so always include this. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6880 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6881 void |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6882 ex_disassemble(exarg_T *eap) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6883 { |
19390
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
6884 char_u *arg = eap->arg; |
19281
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19221
diff
changeset
|
6885 ufunc_T *ufunc; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6886 dfunc_T *dfunc; |
28946
e78e398fff3d
patch 8.2.4995: still a compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28940
diff
changeset
|
6887 isn_T *instr = NULL; // init to shut up gcc warning |
e78e398fff3d
patch 8.2.4995: still a compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28940
diff
changeset
|
6888 int instr_count = 0; // init to shut up gcc warning |
28940
b02044bc8c20
patch 8.2.4992: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28934
diff
changeset
|
6889 compiletype_T compile_type = CT_NONE; |
28934
a712ea475390
patch 8.2.4989: cannot specify a function name for :defcompile
Bram Moolenaar <Bram@vim.org>
parents:
28907
diff
changeset
|
6890 |
a712ea475390
patch 8.2.4989: cannot specify a function name for :defcompile
Bram Moolenaar <Bram@vim.org>
parents:
28907
diff
changeset
|
6891 ufunc = find_func_by_name(arg, &compile_type); |
a712ea475390
patch 8.2.4989: cannot specify a function name for :defcompile
Bram Moolenaar <Bram@vim.org>
parents:
28907
diff
changeset
|
6892 if (ufunc == NULL) |
19390
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
6893 return; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6894 if (func_needs_compiling(ufunc, compile_type) |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6895 && compile_def_function(ufunc, FALSE, compile_type, NULL) == FAIL) |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20433
diff
changeset
|
6896 return; |
20943
1693ca876049
patch 8.2.1023: Vim9: redefining a function uses a new index every time
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
6897 if (ufunc->uf_def_status != UF_COMPILED) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6898 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
6899 semsg(_(e_function_is_not_compiled_str), eap->arg); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6900 return; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6901 } |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
6902 msg((char *)printable_func_name(ufunc)); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6903 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6904 dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6905 switch (compile_type) |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6906 { |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6907 case CT_PROFILE: |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
6908 #ifdef FEAT_PROFILE |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6909 instr = dfunc->df_instr_prof; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6910 instr_count = dfunc->df_instr_prof_count; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6911 break; |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
6912 #endif |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6913 // FALLTHROUGH |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6914 case CT_NONE: |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6915 instr = dfunc->df_instr; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6916 instr_count = dfunc->df_instr_count; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6917 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6918 case CT_DEBUG: |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6919 instr = dfunc->df_instr_debug; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6920 instr_count = dfunc->df_instr_debug_count; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6921 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
6922 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6923 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6924 list_instructions("", instr, instr_count, ufunc); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6925 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6926 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6927 /* |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
6928 * Return TRUE when "tv" is not falsy: non-zero, non-empty string, non-empty |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6929 * list, etc. Mostly like what JavaScript does, except that empty list and |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6930 * empty dictionary are FALSE. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6931 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6932 int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6933 tv2bool(typval_T *tv) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6934 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6935 switch (tv->v_type) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6936 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6937 case VAR_NUMBER: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6938 return tv->vval.v_number != 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6939 case VAR_FLOAT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6940 return tv->vval.v_float != 0.0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6941 case VAR_PARTIAL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6942 return tv->vval.v_partial != NULL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6943 case VAR_FUNC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6944 case VAR_STRING: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6945 return tv->vval.v_string != NULL && *tv->vval.v_string != NUL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6946 case VAR_LIST: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6947 return tv->vval.v_list != NULL && tv->vval.v_list->lv_len > 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6948 case VAR_DICT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6949 return tv->vval.v_dict != NULL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6950 && tv->vval.v_dict->dv_hashtab.ht_used > 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6951 case VAR_BOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6952 case VAR_SPECIAL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6953 return tv->vval.v_number == VVAL_TRUE ? TRUE : FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6954 case VAR_JOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6955 #ifdef FEAT_JOB_CHANNEL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6956 return tv->vval.v_job != NULL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6957 #else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6958 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6959 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6960 case VAR_CHANNEL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6961 #ifdef FEAT_JOB_CHANNEL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6962 return tv->vval.v_channel != NULL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6963 #else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6964 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6965 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6966 case VAR_BLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6967 return tv->vval.v_blob != NULL && tv->vval.v_blob->bv_ga.ga_len > 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6968 case VAR_UNKNOWN: |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
6969 case VAR_ANY: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6970 case VAR_VOID: |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
6971 case VAR_INSTR: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6972 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6973 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6974 return FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6975 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6976 |
22860
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6977 void |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6978 emsg_using_string_as(typval_T *tv, int as_number) |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6979 { |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6980 semsg(_(as_number ? e_using_string_as_number_str |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6981 : e_using_string_as_bool_str), |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6982 tv->vval.v_string == NULL |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6983 ? (char_u *)"" : tv->vval.v_string); |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6984 } |
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6985 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6986 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6987 * If "tv" is a string give an error and return FAIL. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6988 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6989 int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6990 check_not_string(typval_T *tv) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6991 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6992 if (tv->v_type == VAR_STRING) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6993 { |
22860
53acb89ec9f2
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
6994 emsg_using_string_as(tv, TRUE); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6995 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6996 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6997 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6998 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6999 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7000 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7001 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7002 #endif // FEAT_EVAL |