Mercurial > vim
annotate src/vim9execute.c @ 26527:c9231e446fa0
Added tag v8.2.3792 for changeset 33d680d372aa2a38069e01eafd3804cf79e2254c
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Dec 2021 21:15:04 +0100 |
parents | 4a1d2abc2016 |
children | 28745eec1dda |
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 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 #ifdef VMS |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 # include <float.h> |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 #include "vim9.h" |
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 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 // current previous instruction pointer |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 // frame_ptr previous Frame Pointer |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 // var1 space for local variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 // var2 space for local variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 // .... fixed space for max. number of local variables |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 // temp temporary values |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 // .... flexible space for temporary values (can grow big) |
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 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 // 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
|
105 #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
|
106 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
107 void |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
108 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
|
109 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
110 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
|
111 } |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
112 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 /* |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
114 * 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
|
115 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 static int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 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
|
118 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 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
|
120 } |
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 /* |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
123 * 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
|
124 * When "count" is zero an empty list is added to the stack. |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
125 */ |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
126 static int |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
127 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
|
128 { |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
129 list_T *list = list_alloc_with_items(count); |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
130 int idx; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
131 typval_T *tv; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
132 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
133 if (list == NULL) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
134 return FAIL; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
135 for (idx = 0; idx < count; ++idx) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
136 list_set_item(list, idx, STACK_TV_BOT(idx - count)); |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
137 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
138 if (count > 0) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
139 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
|
140 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
|
141 return FAIL; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
142 else |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
143 ++ectx->ec_stack.ga_len; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
144 tv = STACK_TV_BOT(-1); |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
145 tv->v_type = VAR_LIST; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
146 tv->vval.v_list = list; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
147 ++list->lv_refcount; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
148 return OK; |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
149 } |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
150 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
151 /* |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
152 * 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
|
153 * "uf_has_breakpoint". |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
154 */ |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
155 static void |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
156 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
|
157 { |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
158 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
|
159 { |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
160 linenr_T breakpoint; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
161 |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 } |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
166 } |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
167 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
168 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
|
169 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
170 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
171 * 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
|
172 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
173 static int |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
174 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
|
175 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
176 if (dict_stack.ga_growsize == 0) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
177 ga_init2(&dict_stack, (int)sizeof(typval_T), 10); |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
178 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
|
179 return FAIL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
180 ((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
|
181 ++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
|
182 return OK; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
183 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
184 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
185 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
186 * 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
|
187 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
188 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
|
189 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
|
190 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
191 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
|
192 return NULL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
193 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
|
194 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
195 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
196 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
197 * 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
|
198 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
199 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
|
200 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
|
201 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
202 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
|
203 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
204 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
|
205 return NULL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
206 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
|
207 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
|
208 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
|
209 return NULL; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
210 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
211 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
212 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
213 * 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
|
214 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
215 static void |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
216 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
|
217 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
218 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
|
219 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
220 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
|
221 return; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
222 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
223 --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
|
224 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
|
225 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
226 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
227 /* |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
228 * 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
|
229 */ |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
230 static void |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
231 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
|
232 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
233 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
|
234 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
|
235 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
236 |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
237 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 * 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
|
239 * 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
|
240 * called function. |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
241 * If "pt" is not null use "pt->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
|
242 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 * Stack has: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 * - 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
|
245 * - 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
|
246 * - stack frame: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 * - 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
|
248 * - 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
|
249 * - previous frame pointer |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 * - 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
|
251 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 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
|
253 call_dfunc( |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
254 int cdf_idx, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
255 partial_T *pt, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
256 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
|
257 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
|
258 { |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 int varcount; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
266 int idx; |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
267 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
|
268 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
|
269 int res = OK; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 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
|
272 { |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
273 // don't use ufunc->uf_name, it may have been freed |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
274 emsg_funcname(e_func_deleted, |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
275 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
|
276 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 |
23735
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
279 #ifdef FEAT_PROFILE |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
280 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
|
281 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
282 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
|
283 { |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
284 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
|
285 + 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
|
286 ++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
|
287 CLEAR_POINTER(info); |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
288 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
|
289 (((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
|
290 + 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
|
291 } |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
292 } |
23735
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
293 #endif |
7caffd835aa1
patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents:
23725
diff
changeset
|
294 |
24980
2cb78583fada
patch 8.2.3027: Vim9: breakpoint in compiled function not always checked
Bram Moolenaar <Bram@vim.org>
parents:
24978
diff
changeset
|
295 // Update uf_has_breakpoint if needed. |
2cb78583fada
patch 8.2.3027: Vim9: breakpoint in compiled function not always checked
Bram Moolenaar <Bram@vim.org>
parents:
24978
diff
changeset
|
296 update_has_breakpoint(ufunc); |
2cb78583fada
patch 8.2.3027: Vim9: breakpoint in compiled function not always checked
Bram Moolenaar <Bram@vim.org>
parents:
24978
diff
changeset
|
297 |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
298 // 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
|
299 // instructions, may need to still compile them. |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
300 if (func_needs_compiling(ufunc, COMPILE_TYPE(ufunc))) |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
301 { |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
302 res = compile_def_function(ufunc, FALSE, COMPILE_TYPE(ufunc), NULL); |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
303 |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
304 // 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
|
305 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
|
306 } |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25159
diff
changeset
|
307 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
|
308 { |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
309 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
|
310 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
|
311 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
|
312 return FAIL; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
313 } |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
314 |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
315 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
|
316 { |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
317 // 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
|
318 // 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
|
319 // normal_arg |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
320 // optional_arg |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
321 // vararg_1 |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
322 // vararg_2 |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
323 // After creating the list: |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
324 // normal_arg |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
325 // optional_arg |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
326 // vararg-list |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
327 // 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
|
328 // normal_arg |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
329 // After creating the list |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
330 // normal_arg |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
331 // (space for optional_arg) |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
332 // 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
|
333 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
|
334 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
|
335 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
|
336 else |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
337 argcount -= vararg_count; |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
338 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
|
339 return FAIL; |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
340 |
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
341 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
|
342 } |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
343 |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
344 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
|
345 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
|
346 { |
21809
15ed135796fd
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents:
21793
diff
changeset
|
347 if (arg_to_add == -1) |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
348 emsg(_(e_one_argument_too_many)); |
21809
15ed135796fd
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents:
21793
diff
changeset
|
349 else |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
350 semsg(_(e_nr_arguments_too_many), -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
|
351 return FAIL; |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
352 } |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
353 |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
354 // 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
|
355 // - 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
|
356 // - 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
|
357 // - 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
|
358 // - 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
|
359 // 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
|
360 varcount = dfunc->df_varcount + dfunc->df_has_closure; |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
361 if (GA_GROW_FAILS(&ectx->ec_stack, 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
|
362 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
364 // 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
|
365 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
|
366 return FAIL; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
367 ++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
|
368 |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
369 // 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
|
370 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
|
371 { |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
372 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
|
373 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
|
374 return FAIL; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
375 *floc = ectx->ec_funclocal; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
376 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
|
377 } |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
378 |
19981
014daa59ba50
patch 8.2.0546: Vim9: varargs implementation is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
379 // 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
|
380 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
|
381 *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
|
382 |
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
383 // 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
|
384 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
|
385 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
|
386 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
|
387 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 // 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 (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
|
394 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
|
395 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
|
396 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
|
397 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 // Initialize local variables |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
399 for (idx = 0; idx < dfunc->df_varcount; ++idx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 STACK_TV_BOT(STACK_FRAME_SIZE + idx)->v_type = VAR_UNKNOWN; |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
401 if (dfunc->df_has_closure) |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
402 { |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
403 typval_T *tv = STACK_TV_BOT(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
|
404 |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
405 tv->v_type = VAR_NUMBER; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
406 tv->vval.v_number = 0; |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
407 } |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
408 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
|
409 |
23699
317018f62643
patch 8.2.2391: memory leak when creating a global function with closure
Bram Moolenaar <Bram@vim.org>
parents:
23697
diff
changeset
|
410 if (pt != NULL || ufunc->uf_partial != NULL |
317018f62643
patch 8.2.2391: memory leak when creating a global function with closure
Bram Moolenaar <Bram@vim.org>
parents:
23697
diff
changeset
|
411 || (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
|
412 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
413 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
|
414 |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
415 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
|
416 return FAIL; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
417 if (pt != NULL) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
418 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
419 ref->or_outer = &pt->pt_outer; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
420 ++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
|
421 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
|
422 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
423 else if (ufunc->uf_partial != NULL) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
424 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
425 ref->or_outer = &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
|
426 ++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
|
427 ref->or_partial = ufunc->uf_partial; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
428 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
429 else |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
430 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
431 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
|
432 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
|
433 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
434 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
|
435 return FAIL; |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
436 } |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
437 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 } |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
443 ectx->ec_outer_ref = ref; |
23557
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
444 } |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
445 else |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
446 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
|
447 |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
448 ++ufunc->uf_calls; |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
449 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 // 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
|
451 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
|
452 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
|
453 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
|
454 if (entry != NULL) |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
455 { |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
456 // 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
|
457 // 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
|
458 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
|
459 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
|
460 } |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
461 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
462 // 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
|
463 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
|
464 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 // Get pointer to item in the stack. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 #define STACK_TV(idx) (((typval_T *)ectx->ec_stack.ga_data) + idx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 /* |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
472 * 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
|
473 * 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
|
474 * 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
|
475 * 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
|
476 * 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
|
477 */ |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
478 static int |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
479 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
|
480 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
481 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
|
482 + 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
|
483 int argcount; |
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
484 int top; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
485 int idx; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
486 typval_T *tv; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
487 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
|
488 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
|
489 varnumber_T closure_count; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
490 |
22324
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
491 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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 |
22324
a4ed0de125d9
patch 8.2.1711: Vim9: leaking memory when using partial
Bram Moolenaar <Bram@vim.org>
parents:
22320
diff
changeset
|
500 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
|
501 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
|
502 |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
503 // 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
|
504 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
|
505 { |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
506 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
|
507 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
|
508 |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
509 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
|
510 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
|
511 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
|
512 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
|
513 { |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
514 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
|
515 int i; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
516 |
20297
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
517 // A Reference in a local variables 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
|
518 // unreferenced on return. |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
519 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
|
520 { |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
521 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
|
522 + 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
|
523 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
|
524 --refcount; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
525 } |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
526 if (refcount > 1) |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
527 { |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
528 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
|
529 break; |
934657e365e5
patch 8.2.0697: Vim9: memory leak when using nested function
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
530 } |
20257
683c2da4982b
patch 8.2.0684: Vim9: memory leak when using lambda
Bram Moolenaar <Bram@vim.org>
parents:
20255
diff
changeset
|
531 } |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
532 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
533 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
534 if (closure_in_use) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
535 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
536 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
|
537 typval_T *stack; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
538 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
539 // 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
|
540 // 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
|
541 if (funcstack == NULL) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
542 return FAIL; |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
543 funcstack->fs_var_offset = argcount + STACK_FRAME_SIZE; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
544 funcstack->fs_ga.ga_len = funcstack->fs_var_offset + dfunc->df_varcount; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
545 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
|
546 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
|
547 if (stack == NULL) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
548 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
549 vim_free(funcstack); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
550 return FAIL; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
551 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
552 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
553 // Move or copy the arguments. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
554 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
|
555 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
556 tv = STACK_TV(top + idx); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
557 if (free_arguments) |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
558 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
559 *(stack + idx) = *tv; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
560 tv->v_type = VAR_UNKNOWN; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
561 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
562 else |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
563 copy_tv(tv, stack + idx); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
564 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
565 // Move the local variables. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
566 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
|
567 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
568 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
|
569 |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
570 // 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
|
571 // 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
|
572 // 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
|
573 // then the funcstack is unused. We need to count how many we have |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
574 // so we need when to check. |
20297
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
575 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
|
576 { |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
577 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
|
578 |
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
579 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
|
580 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
|
581 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
|
582 ++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
|
583 } |
5f0611bc6377
patch 8.2.0704: Vim9: memory leak in disassemble test
Bram Moolenaar <Bram@vim.org>
parents:
20295
diff
changeset
|
584 |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
585 *(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
|
586 tv->v_type = VAR_UNKNOWN; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
587 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
588 |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
589 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
|
590 { |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
591 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
|
592 - 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
|
593 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
|
594 { |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
595 ++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
|
596 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
|
597 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
|
598 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
|
599 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
600 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
601 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
602 |
22371
15003353a464
patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents:
22324
diff
changeset
|
603 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
|
604 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
|
605 - 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
|
606 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
|
607 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
|
608 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
|
609 |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
610 return OK; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
611 } |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
612 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
613 /* |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
614 * 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
|
615 * 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
|
616 * 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
|
617 * referencing the funcstack have a reference count of one. |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
618 */ |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
619 void |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
620 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
|
621 { |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
622 int i; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
623 garray_T *gap = &funcstack->fs_ga; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
624 int done = 0; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
625 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
626 if (funcstack->fs_refcount > funcstack->fs_min_refcount) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
627 return; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
628 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
|
629 { |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
630 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
|
631 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
632 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
|
633 && 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
|
634 && 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
|
635 ++done; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
636 } |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
637 if (done == funcstack->fs_min_refcount) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
638 { |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
639 typval_T *stack = gap->ga_data; |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
640 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
641 // All partials referencing the funcstack have a reference count of |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
642 // one, thus the funcstack is no longer of use. |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
643 for (i = 0; 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
|
644 clear_tv(stack + i); |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
645 vim_free(stack); |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
646 vim_free(funcstack); |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
647 } |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
648 } |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
649 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22527
diff
changeset
|
650 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 * 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
|
652 */ |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
653 static int |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
654 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
|
655 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 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
|
657 int ret_idx; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
658 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
|
659 + ectx->ec_dfunc_idx; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
660 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
|
661 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
|
662 estack_T *entry; |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
663 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
|
664 + 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
|
665 funclocal_T *floc; |
dd87d08f86de
patch 8.2.2814: Vim9: unused variable
Bram Moolenaar <Bram@vim.org>
parents:
24545
diff
changeset
|
666 #ifdef FEAT_PROFILE |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
667 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
|
668 + prev_dfunc_idx; |
24549
dd87d08f86de
patch 8.2.2814: Vim9: unused variable
Bram Moolenaar <Bram@vim.org>
parents:
24545
diff
changeset
|
669 |
23976
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
670 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
|
671 { |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
672 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
|
673 |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
674 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
|
675 || (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
|
676 { |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
677 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
|
678 + 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
|
679 --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
|
680 } |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
681 } |
03819ebd3e6d
patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents:
23934
diff
changeset
|
682 #endif |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
683 // TODO: when is it safe to delete the function when it is no longer used? |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24128
diff
changeset
|
684 --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
|
685 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 // 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
|
687 entry = estack_pop(); |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21168
diff
changeset
|
688 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
|
689 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
|
690 |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
691 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
|
692 return FAIL; |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
693 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
694 // Clear the arguments. |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
695 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
|
696 clear_tv(STACK_TV(idx)); |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
697 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
698 // 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
|
699 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
|
700 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
|
701 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
|
702 |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
703 // 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
|
704 // 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
|
705 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
|
706 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
|
707 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
|
708 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
709 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
|
710 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
711 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
|
712 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
|
713 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
|
714 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
|
715 } |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
716 |
19328
e99e6d794597
patch 8.2.0222: Vim9: optional function arguments don't work yet
Bram Moolenaar <Bram@vim.org>
parents:
19316
diff
changeset
|
717 // 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
|
718 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
|
719 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
|
720 + 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
|
721 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
|
722 + 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
|
723 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
|
724 + 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
|
725 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
|
726 + 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
|
727 // 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
|
728 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
|
729 + 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
|
730 |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
731 if (floc == NULL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
732 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
|
733 else |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
734 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
735 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
|
736 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
|
737 } |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
738 |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
739 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
|
740 { |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
741 // 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
|
742 // 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
|
743 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
|
744 *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
|
745 } |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
746 else |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
747 // 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
|
748 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
|
749 |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
750 funcdepth_decrement(); |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
751 --ex_nesting_level; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
752 return OK; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 #undef STACK_TV |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 * 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
|
759 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 static int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 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
|
762 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 int idx; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 typval_T *tv; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 // 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
|
767 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
|
768 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
|
769 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
|
770 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 // 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
|
772 if (argcount > 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 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
|
774 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
|
775 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 ++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
|
778 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 // 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
|
780 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
|
781 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
|
782 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
|
783 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 |
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
|
787 // Ugly global to avoid passing the execution context around through many |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
788 // layers. |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
789 static ectx_T *current_ectx = NULL; |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21299
diff
changeset
|
790 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 * 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
|
793 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 static int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 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
|
796 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 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
|
804 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
|
805 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
|
806 |
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
|
807 // 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
|
808 // 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
|
809 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
|
810 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
|
811 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
|
812 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
|
813 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 // Clear the arguments. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 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
|
816 clear_tv(&argvars[idx]); |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20283
diff
changeset
|
817 |
23177
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23156
diff
changeset
|
818 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
|
819 return FAIL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 * Execute a user defined function. |
23557
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23553
diff
changeset
|
825 * 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
|
826 * 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
|
827 * 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
|
828 * 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
|
829 * "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
|
830 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 static int |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
832 call_ufunc( |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
833 ufunc_T *ufunc, |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
834 partial_T *pt, |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
835 int argcount, |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
836 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
|
837 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
|
838 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
|
839 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 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
|
841 funcexe_T funcexe; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 int error; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 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
|
844 int did_emsg_before = did_emsg; |
24932
afaa7f3aae56
patch 8.2.3003: Vim9: closure compiled with wrong compile type
Bram Moolenaar <Bram@vim.org>
parents:
24918
diff
changeset
|
845 compiletype_T compile_type = COMPILE_TYPE(ufunc); |
afaa7f3aae56
patch 8.2.3003: Vim9: closure compiled with wrong compile type
Bram Moolenaar <Bram@vim.org>
parents:
24918
diff
changeset
|
846 |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
847 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
|
848 && 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
|
849 == 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
|
850 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
|
851 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
|
852 { |
23254
4b7e996354e0
patch 8.2.2173: Vim9: get internal error when assigning to undefined variable
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
853 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
|
854 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
|
855 { |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
856 if (error == FCERR_TOOMANY) |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
857 semsg(_(e_toomanyarg), ufunc->uf_name); |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
858 else |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
859 semsg(_(e_toofewarg), ufunc->uf_name); |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
860 return FAIL; |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
861 } |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
862 |
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
|
863 // 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
|
864 // that was defined later: we can call it directly next time. |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
865 // TODO: what if the function was deleted and then defined again? |
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
|
866 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
|
867 { |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
868 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
|
869 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
|
870 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
|
871 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
|
872 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
873 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
|
874 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 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
|
877 return FAIL; |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19981
diff
changeset
|
878 CLEAR_FIELD(funcexe); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 funcexe.evaluate = TRUE; |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
880 funcexe.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
|
881 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 // 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
|
883 // TODO: add selfdict if there is one |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 error = call_user_func_check(ufunc, argcount, argvars, |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
885 STACK_TV_BOT(-1), &funcexe, funcexe.selfdict); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 // Clear the arguments. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 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
|
889 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
|
890 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 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
|
892 { |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
893 user_func_error(error, ufunc->uf_name, &funcexe); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 } |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
896 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
|
897 // 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
|
898 return FAIL; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 /* |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
903 * 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
|
904 */ |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
905 static void |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
906 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
|
907 { |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
908 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
|
909 { |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
910 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
|
911 undo_cmdmod(&cmdmod); |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
912 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
|
913 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
|
914 } |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
915 } |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
916 |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
917 /* |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
918 * 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
|
919 * pressed. |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
920 */ |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
921 static int |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
922 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
|
923 { |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
924 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
|
925 } |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
926 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
927 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 * 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
|
929 * 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
|
930 * "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
|
931 * 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
|
932 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 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
|
934 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
|
935 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
|
936 int argcount, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
937 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
|
938 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
|
939 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
|
940 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 ufunc_T *ufunc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 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
|
944 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 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
|
946 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 if (func_idx < 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 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
|
949 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
|
950 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 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
|
952 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20172
diff
changeset
|
954 ufunc = find_func(name, FALSE, NULL); |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
955 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
956 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
|
957 { |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
958 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
|
959 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
960 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
|
961 // loaded a package, search for the function again |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
962 ufunc = find_func(name, FALSE, NULL); |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
963 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25605
diff
changeset
|
964 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
|
965 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
|
966 } |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
967 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 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
|
969 { |
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
|
970 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
|
971 { |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
972 int i; |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
973 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
|
974 |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
975 // 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
|
976 // 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
|
977 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
|
978 { |
24077
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
979 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
|
980 |
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
|
981 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
|
982 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
|
983 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
|
984 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
|
985 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
|
986 &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
|
987 return FAIL; |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
988 } |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
989 } |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24014
diff
changeset
|
990 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
991 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
|
992 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 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
|
998 call_partial( |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
999 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
|
1000 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
|
1001 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
|
1002 { |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1003 int argcount = argcount_arg; |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 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
|
1010 { |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1011 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
|
1012 int i; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1013 |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1014 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
|
1015 { |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1016 // 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
|
1017 // 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
|
1018 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
|
1019 return FAIL; |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1020 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
|
1021 *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
|
1022 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
|
1023 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
|
1024 |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
1025 // 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
|
1026 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
|
1027 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
|
1028 } |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1029 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
|
1030 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 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
|
1032 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
|
1033 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 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
|
1035 } |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
1036 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
|
1037 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
|
1038 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
|
1039 { |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1045 // 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
|
1046 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
|
1047 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
|
1048 res = FAIL; |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1049 else |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1050 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
|
1051 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
|
1052 } |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21969
diff
changeset
|
1053 |
23582
b875bbd517a6
patch 8.2.2333: Vim9: warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
23580
diff
changeset
|
1054 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
|
1055 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 if (called_emsg == called_emsg_before) |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20283
diff
changeset
|
1057 semsg(_(e_unknownfunc), |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20283
diff
changeset
|
1058 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
|
1059 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 /* |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1065 * 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
|
1066 * TRUE. |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1067 */ |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1068 static int |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1069 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
|
1070 { |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1071 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
|
1072 { |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1073 emsg(_(error)); |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1074 return TRUE; |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1075 } |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1076 return FALSE; |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1077 } |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1078 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1079 /* |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1080 * 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
|
1081 */ |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1082 static int |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1083 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
|
1084 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1085 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
|
1086 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1087 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
|
1088 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
|
1089 return FAIL; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1090 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1091 return OK; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1092 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1093 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
1094 /* |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1095 * 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
|
1096 * 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
|
1097 */ |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1098 static void |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1099 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
|
1100 { |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1101 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
|
1102 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
|
1103 |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1104 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
|
1105 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
|
1106 save_funccal(&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
|
1107 set_var_const(name, 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
|
1108 restore_funccal(); |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1109 } |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1110 |
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
|
1111 /* |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1112 * 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
|
1113 * 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
|
1114 */ |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1115 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
|
1116 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
|
1117 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1118 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
|
1119 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1120 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
|
1121 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1122 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
|
1123 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1124 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
|
1125 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1126 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
|
1127 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
|
1128 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
|
1129 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
|
1130 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
|
1131 |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1132 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
|
1133 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
|
1134 { |
24806
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1135 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
|
1136 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
|
1137 |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1138 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
|
1139 |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1140 // 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
|
1141 // 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
|
1142 // 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
|
1143 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
|
1144 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
|
1145 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
|
1146 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
|
1147 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
|
1148 { |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1149 *e = NUL; |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25814
diff
changeset
|
1150 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
|
1151 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
|
1152 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
|
1153 { |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1154 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
|
1155 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
|
1156 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
|
1157 } |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1158 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
|
1159 } |
28127371aa18
patch 8.2.2941: Vim9: using does not handle a list of strings
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
1160 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
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 } |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
1166 // 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
|
1167 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
|
1168 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
|
1169 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1170 } |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23735
diff
changeset
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1176 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
|
1177 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1178 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
1179 /* |
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
|
1180 * 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
|
1181 */ |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1182 static void |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1183 allocate_if_null(typval_T *tv) |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1184 { |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1185 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
|
1186 { |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1187 case VAR_LIST: |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1188 if (tv->vval.v_list == NULL) |
23839
23d6ead591c1
patch 8.2.2461: Coverity warns for unchecked return value
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
1189 (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
|
1190 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
|
1191 case VAR_DICT: |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1192 if (tv->vval.v_dict == NULL) |
23839
23d6ead591c1
patch 8.2.2461: Coverity warns for unchecked return value
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
1193 (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
|
1194 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
|
1195 case VAR_BLOB: |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
1196 if (tv->vval.v_blob == NULL) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
1197 (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
|
1198 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
|
1199 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
|
1200 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
|
1201 } |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
1202 } |
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
|
1203 |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1204 /* |
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
|
1205 * 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
|
1206 * 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
|
1207 * 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
|
1208 */ |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1209 char_u * |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1210 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
|
1211 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1212 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
|
1213 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
|
1214 size_t slen; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1215 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1216 if (str == NULL) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1217 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1218 slen = STRLEN(str); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1219 |
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
|
1220 // 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
|
1221 // 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
|
1222 // 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
|
1223 if (index < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1224 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1225 int clen = 0; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1226 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1227 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
|
1228 { |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1229 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
|
1230 ++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
|
1231 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
|
1232 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
|
1233 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
|
1234 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
|
1235 } |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1236 nchar = clen + index; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1237 if (nchar < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1238 // 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
|
1239 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1240 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1241 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1242 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
|
1243 { |
f49f80a0905d
patch 8.2.2654: Vim9: getting a character from a string can be slow
Bram Moolenaar <Bram@vim.org>
parents:
24220
diff
changeset
|
1244 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
|
1245 ++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
|
1246 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
|
1247 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
|
1248 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
|
1249 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
|
1250 } |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1251 if (nbyte >= slen) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1252 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
|
1253 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
|
1254 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1255 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1256 /* |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1257 * 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
|
1258 * "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
|
1259 * 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
|
1260 * 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
|
1261 * 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
|
1262 */ |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1263 static long |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1264 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
|
1265 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1266 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
|
1267 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
|
1268 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1269 if (nchar >= 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1270 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1271 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
|
1272 { |
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
|
1273 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
|
1274 --nchar; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1275 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1276 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1277 else |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1278 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1279 nbyte = str_len; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1280 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
|
1281 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1282 --nbyte; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1283 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
|
1284 ++nchar; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1285 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1286 if (nchar < 0) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1287 return -1; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1288 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1289 return (long)nbyte; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1290 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1291 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1292 /* |
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
|
1293 * 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
|
1294 * 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
|
1295 * "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
|
1296 * 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
|
1297 */ |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1298 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
|
1299 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
|
1300 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1301 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
|
1302 size_t slen; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1303 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1304 if (str == NULL) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1305 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1306 slen = STRLEN(str); |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1307 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
|
1308 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
|
1309 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
|
1310 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
|
1311 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
|
1312 else |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1313 { |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1314 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
|
1315 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
|
1316 // 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
|
1317 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
|
1318 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1319 |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1320 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
|
1321 return NULL; |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1322 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
|
1323 } |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23543
diff
changeset
|
1324 |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1325 /* |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1326 * 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
|
1327 * 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
|
1328 * 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
|
1329 */ |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1330 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
|
1331 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
|
1332 { |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1333 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
|
1334 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
|
1335 : ((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
|
1336 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
|
1337 |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1338 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
|
1339 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1340 // 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
|
1341 // 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
|
1342 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
|
1343 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
|
1344 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
|
1345 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
|
1346 } |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1347 sv = ((svar_T *)si->sn_var_vals.ga_data) + sref->sref_idx; |
25425
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25350
diff
changeset
|
1348 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
|
1349 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
1350 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
|
1351 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
|
1352 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
|
1353 } |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1354 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
|
1355 } |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1356 |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
1357 /* |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1358 * 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
|
1359 * characters. |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1360 */ |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1361 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
|
1362 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
|
1363 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
|
1364 void *cookie, |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1365 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
|
1366 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
|
1367 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1368 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
|
1369 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
|
1370 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
|
1371 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1372 if (*sp->nextline == NUL) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1373 return NULL; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1374 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
|
1375 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
|
1376 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1377 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
|
1378 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
|
1379 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1380 else |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1381 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1382 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
|
1383 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
|
1384 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1385 return line; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1386 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1387 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1388 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 * 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
|
1390 * 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
|
1391 * "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
|
1392 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 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
|
1394 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
|
1395 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
|
1396 int argcount, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1397 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
|
1398 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
|
1399 { |
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
|
1400 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
|
1401 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
|
1402 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
1403 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
|
1404 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
|
1405 { |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1406 dictitem_T *v; |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1407 |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1408 v = find_var(name, NULL, FALSE); |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1409 if (v == NULL) |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1410 { |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1411 semsg(_(e_unknownfunc), name); |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1412 return FAIL; |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1413 } |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1414 if (v->di_tv.v_type != VAR_PARTIAL && v->di_tv.v_type != VAR_FUNC) |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1415 { |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1416 semsg(_(e_unknownfunc), name); |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1417 return FAIL; |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
1418 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1419 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
|
1420 } |
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
|
1421 return res; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 /* |
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
|
1425 * 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
|
1426 * 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
|
1427 */ |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1428 int |
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
|
1429 fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1430 { |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1431 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
|
1432 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
|
1433 |
23699
317018f62643
patch 8.2.2391: memory leak when creating a global function with closure
Bram Moolenaar <Bram@vim.org>
parents:
23697
diff
changeset
|
1434 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
|
1435 { |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1436 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
|
1437 + 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
|
1438 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1439 // The closure may need to find arguments and local variables in the |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1440 // current stack. |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
1441 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
|
1442 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
|
1443 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
|
1444 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1445 // 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
|
1446 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
|
1447 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
|
1448 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1449 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
|
1450 ++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
|
1451 } |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1452 } |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1453 |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1454 // If this function returns and the closure is still being used, we |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1455 // need to make a copy of the context (arguments and local variables). |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1456 // 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
|
1457 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
|
1458 { |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1459 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
|
1460 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
|
1461 } |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
1462 // 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
|
1463 // 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
|
1464 ++(((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
|
1465 + 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
|
1466 |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1467 ((partial_T **)ectx->ec_funcrefs.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
|
1468 [ectx->ec_funcrefs.ga_len] = 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
|
1469 ++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
|
1470 ++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
|
1471 } |
23699
317018f62643
patch 8.2.2391: memory leak when creating a global function with closure
Bram Moolenaar <Bram@vim.org>
parents:
23697
diff
changeset
|
1472 ++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
|
1473 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
|
1474 } |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
1475 |
25605
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1476 /* |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1477 * 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
|
1478 */ |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1479 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
|
1480 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
|
1481 { |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1482 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
|
1483 |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1484 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
|
1485 // 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
|
1486 // command. |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1487 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
|
1488 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
|
1489 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
|
1490 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
|
1491 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
|
1492 || 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
|
1493 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
|
1494 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
|
1495 } |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
1496 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1497 // 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
|
1498 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
|
1499 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
|
1500 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
|
1501 }; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1502 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1503 // used for substitute_instr |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1504 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
|
1505 ectx_T *subs_ectx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1506 isn_T *subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1507 int subs_status; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1508 } 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
|
1509 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 // Get pointer to item in the stack. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1511 #define STACK_TV(idx) (((typval_T *)ectx->ec_stack.ga_data) + idx) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 // Get pointer to item at the bottom of the stack, -1 is the bottom. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 #undef STACK_TV_BOT |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1515 #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
|
1516 |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19964
diff
changeset
|
1517 // Get pointer to a local variable on the stack. Negative for arguments. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1518 #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
|
1519 |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1520 // 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
|
1521 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
|
1522 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
|
1523 |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1524 /* |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1525 * 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
|
1526 * 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
|
1527 */ |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1528 typval_T * |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1529 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
|
1530 { |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1531 int idx; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1532 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
|
1533 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
|
1534 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
|
1535 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
|
1536 |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1537 if (ectx == NULL) |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1538 return NULL; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1539 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
|
1540 |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1541 // 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
|
1542 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
|
1543 { |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1544 if (STRCMP(((char_u **)dfunc->df_var_names.ga_data)[idx], name) == 0) |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1545 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
|
1546 } |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1547 |
24948
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1548 // 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
|
1549 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
|
1550 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
|
1551 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
|
1552 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
|
1553 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
|
1554 - varargs_off + idx); |
5c418c774f95
patch 8.2.3011: Vim9: cannot get argument values during debugging
Bram Moolenaar <Bram@vim.org>
parents:
24936
diff
changeset
|
1555 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
|
1556 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
|
1557 |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1558 return NULL; |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1559 } |
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
1560 |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1561 /* |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1562 * 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
|
1563 * 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
|
1564 */ |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1565 int |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1566 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
|
1567 { |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1568 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
|
1569 } |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1570 |
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
|
1571 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
|
1572 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
|
1573 { |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1574 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
|
1575 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
|
1576 + 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
|
1577 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
|
1578 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
|
1579 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
|
1580 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
|
1581 |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1582 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
|
1583 { |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1584 linenr_T breakpoint; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1585 |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
1586 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
|
1587 return; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1588 |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1589 // 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
|
1590 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
|
1591 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
|
1592 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
|
1593 return; |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1594 } |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
1595 |
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
|
1596 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
|
1597 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
|
1598 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
|
1599 |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1600 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
|
1601 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
|
1602 || 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
|
1603 || 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
|
1604 { |
26252
3d92646fe6c8
patch 8.2.3657: Vim9: debug text misses one line of return statement
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
1605 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
|
1606 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
|
1607 } |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1608 |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1609 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
|
1610 { |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1611 ga_init2(&ga, sizeof(char_u *), 10); |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1612 for (lnum = iptr->isn_lnum; lnum < end_lnum; ++lnum) |
24960
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
1613 { |
25159
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
1614 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
|
1615 |
b2a6a71a11e8
patch 8.2.3116: Vim9: crash when debugging a function with line continuation
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
1616 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
|
1617 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
|
1618 p = skipwhite(p); |
24960
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
1619 if (*p == '#') |
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
1620 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
|
1621 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
|
1622 ((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
|
1623 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
|
1624 break; |
64b70a958f19
patch 8.2.3017: Vim9: debugger shows too many lines
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
1625 } |
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
|
1626 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
|
1627 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
|
1628 } |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1629 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
|
1630 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
|
1631 |
9b7fac4c70a0
patch 8.2.3014: Coverity warns for freeing static string
Bram Moolenaar <Bram@vim.org>
parents:
24952
diff
changeset
|
1632 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
|
1633 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
|
1634 |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1635 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
|
1636 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
|
1637 } |
ffe784fdec57
patch 8.2.3013: Vim: when debugging only first line of command is displayed
Bram Moolenaar <Bram@vim.org>
parents:
24948
diff
changeset
|
1638 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1639 /* |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1640 * 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
|
1641 * Return OK or FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1642 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1643 static int |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1644 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
|
1645 { |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
1646 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
|
1647 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
|
1648 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
|
1649 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
1650 // 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
|
1651 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
|
1652 |
24637
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24614
diff
changeset
|
1653 // 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
|
1654 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
|
1655 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 for (;;) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 { |
25324
af0fd37ae687
patch 8.2.3199: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
1658 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
|
1659 isn_T *iptr; |
25324
af0fd37ae687
patch 8.2.3199: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
1660 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
|
1661 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
1662 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
|
1663 { |
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
1664 line_breakcheck(); |
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
1665 breakcheck_count = 0; |
fd1b6f4f497e
patch 8.2.0759: Vim9: missing changes for performance improvements
Bram Moolenaar <Bram@vim.org>
parents:
20353
diff
changeset
|
1666 } |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
1667 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
|
1668 { |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
1669 // 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
|
1670 got_int = FALSE; |
19736
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19726
diff
changeset
|
1671 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
|
1672 goto theend; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
1673 did_throw = TRUE; |
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
1674 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
1676 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
|
1677 { |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
1678 // 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
|
1679 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
|
1680 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
|
1681 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
|
1682 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
|
1683 *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
|
1684 } |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
1685 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
1686 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
|
1687 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1688 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
|
1689 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
|
1690 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
|
1691 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 // 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
|
1693 // 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
|
1694 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
|
1695 { |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
1696 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
|
1697 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
|
1698 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
|
1699 // 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
|
1700 // 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
|
1701 --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
|
1702 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
|
1703 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1704 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
|
1705 { |
25082
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1706 if (trycmd->tcd_in_catch) |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1707 { |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1708 // 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
|
1709 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
|
1710 trycmd->tcd_finally_idx = 0; |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1711 } |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1712 else |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1713 // jump to first ":catch" |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
1714 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
|
1715 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
|
1716 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
|
1717 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
|
1718 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 { |
21787
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1721 // 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
|
1722 // 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
|
1723 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
|
1724 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
|
1725 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
|
1726 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
|
1727 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
|
1728 ++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
|
1729 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
|
1730 { |
21787
837e6a429950
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1731 // 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
|
1732 need_rethrow = TRUE; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1733 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
|
1734 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 goto done; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1738 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
|
1739 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 continue; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1744 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
|
1745 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
|
1746 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 // 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
|
1748 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
|
1749 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
|
1750 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
|
1751 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1753 // 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
|
1754 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
|
1755 { |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1756 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
|
1757 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
|
1758 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1759 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
|
1760 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
|
1761 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
|
1762 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
|
1763 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
|
1764 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
|
1765 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
|
1766 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
|
1767 == FAIL |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1768 || did_emsg) |
24830
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
1769 { |
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
1770 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
|
1771 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
|
1772 } |
f7445dcba17f
patch 8.2.2953: Vim9: leaking memory when using heredoc script
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
1773 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
|
1774 } |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1775 break; |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
1776 |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1777 // 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
|
1778 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
|
1779 { |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1780 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
|
1781 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
|
1782 |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1783 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
|
1784 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
|
1785 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
|
1786 ea.cmd = 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
|
1787 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
|
1788 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
|
1789 goto on_error; |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1790 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
|
1791 error = ex_range_without_command(&ea); |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1792 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
|
1793 { |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1794 SOURCING_LNUM = iptr->isn_lnum; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1795 emsg(error); |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1796 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
|
1797 } |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1798 } |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1799 break; |
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
1800 |
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
|
1801 // 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
|
1802 // 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
|
1803 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
|
1804 { |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
1805 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
|
1806 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
|
1807 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
|
1808 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 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
|
1814 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
|
1815 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
|
1816 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
|
1817 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
|
1818 ++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
|
1819 } |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
1820 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
|
1821 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1822 // 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
|
1823 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
|
1824 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1825 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
|
1826 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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 ++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
|
1832 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1833 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
|
1834 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
|
1835 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
|
1836 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1837 break; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
1838 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1839 // 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
|
1840 case ISN_SUBSTITUTE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1841 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1842 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
|
1843 source_cookie_T cookie; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1844 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
|
1845 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
|
1846 int res; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1847 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1848 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
|
1849 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
|
1850 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
|
1851 substitute_instr = &subs_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1852 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1853 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
|
1854 // 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
|
1855 CLEAR_FIELD(cookie); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1856 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
|
1857 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
|
1858 getsourceline, &cookie, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1859 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
|
1860 substitute_instr = save_instr; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1861 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1862 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
|
1863 || 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
|
1864 goto on_error; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1865 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1866 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1867 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1868 case ISN_FINISH: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1869 goto done; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1870 |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1871 case ISN_REDIRSTART: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1872 // 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
|
1873 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
|
1874 goto on_error; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1875 |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1876 // 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
|
1877 // redirection ends. |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1878 init_redir_ga(); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1879 redir_vname = 1; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1880 break; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1881 |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1882 case ISN_REDIREND: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1883 { |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1884 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
|
1885 |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1886 // 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
|
1887 clear_redir_lval(); |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1888 redir_vname = 0; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1889 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1890 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
|
1891 { |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1892 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
|
1893 goto theend; |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1894 } |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1895 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
|
1896 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
|
1897 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
|
1898 ++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
|
1899 } |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1900 break; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
1901 |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1902 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
|
1903 #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
|
1904 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
|
1905 goto on_error; |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
1906 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1907 break; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1908 |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1909 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
|
1910 #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
|
1911 { |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1912 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
|
1913 int res; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1914 |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1915 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
|
1916 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
|
1917 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
|
1918 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
|
1919 --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
|
1920 tv = STACK_TV_BOT(0); |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1921 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
|
1922 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
|
1923 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
|
1924 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
|
1925 } |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
1926 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1927 break; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
1928 |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1929 // 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
|
1930 case ISN_EXECCONCAT: |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1931 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1932 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
|
1933 size_t len = 0; |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1934 int pass; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1935 int i; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1936 char_u *cmd = NULL; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1937 char_u *str; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1938 |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1939 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
|
1940 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1941 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
|
1942 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1943 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
|
1944 str = tv->vval.v_string; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1945 if (str != NULL && *str != NUL) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1946 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1947 if (pass == 2) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1948 STRCPY(cmd + len, str); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1949 len += STRLEN(str); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1950 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1951 if (pass == 2) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1952 clear_tv(tv); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1953 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1954 if (pass == 1) |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1955 { |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1956 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
|
1957 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
|
1958 goto theend; |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1959 len = 0; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1960 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1961 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1962 |
20172
1d84eaed0ec8
patch 8.2.0641: Vim9: not expanded in :hardcopy and syn-include
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1963 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
|
1964 do_cmdline_cmd(cmd); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1965 vim_free(cmd); |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1966 } |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1967 break; |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
1968 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 // execute :echo {string} ... |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 case ISN_ECHO: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 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
|
1973 int atstart = TRUE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 int needclr = TRUE; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1975 int idx; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 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
|
1978 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 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
|
1980 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
|
1981 &atstart, &needclr); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 } |
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
|
1984 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
|
1985 msg_clr_eos(); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
1986 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
|
1987 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
1990 // :execute {string} ... |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
1991 // :echomsg {string} ... |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
1992 // :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
|
1993 // :echoerr {string} ... |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
1994 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
|
1995 case ISN_ECHOMSG: |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
1996 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
|
1997 case ISN_ECHOERR: |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
1998 { |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
1999 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
|
2000 garray_T ga; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2001 char_u buf[NUMBUFLEN]; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2002 char_u *p; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2003 int len; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2004 int failed = FALSE; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2005 int idx; |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2006 |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2007 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
|
2008 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
|
2009 { |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2010 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
|
2011 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
|
2012 { |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2013 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
|
2014 || 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
|
2015 { |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2016 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
|
2017 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
|
2018 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
|
2019 break; |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2020 } |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2021 else |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2022 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
|
2023 } |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2024 else |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2025 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
|
2026 |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2027 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
|
2028 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
|
2029 failed = TRUE; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2030 else |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2031 { |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2032 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
|
2033 ((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
|
2034 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
|
2035 ga.ga_len += len; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2036 } |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2037 clear_tv(tv); |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2038 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2039 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
|
2040 if (failed) |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
2041 { |
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
2042 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
|
2043 goto on_error; |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
2044 } |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2045 |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2046 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
|
2047 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2048 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
|
2049 { |
5edd776d886d
patch 8.2.1516: Vim9: error for :exe has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
2050 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
|
2051 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
|
2052 if (did_emsg) |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
2053 { |
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
2054 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
|
2055 goto on_error; |
22952
629472e2e4c5
patch 8.2.2023: Vim: memory leak when :execute fails
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
2056 } |
21933
5edd776d886d
patch 8.2.1516: Vim9: error for :exe has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
2057 } |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2058 else |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2059 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2060 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
|
2061 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
|
2062 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2063 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
|
2064 out_flush(); |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2065 } |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
2066 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
|
2067 { |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
2068 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
|
2069 TRUE); |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
2070 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
|
2071 } |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2072 else |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2073 { |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2074 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
|
2075 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
|
2076 } |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2077 } |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2078 } |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2079 ga_clear(&ga); |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2080 } |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2081 break; |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19463
diff
changeset
|
2082 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 // 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
|
2084 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
|
2085 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
|
2086 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 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
|
2088 ++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
|
2089 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 // load v: variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 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
|
2093 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
|
2094 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2095 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
|
2096 ++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
|
2097 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2099 // 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
|
2100 case ISN_LOADSCRIPT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2101 { |
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
|
2102 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
|
2103 svar_T *sv; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2104 |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
2105 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
|
2106 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
|
2107 goto theend; |
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
|
2108 allocate_if_null(sv->sv_tv); |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2109 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
|
2110 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2111 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
|
2112 ++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
|
2113 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2114 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 // load s: variable in old script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 case ISN_LOADS: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 { |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2119 hashtab_T *ht = &SCRIPT_VARS( |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2120 iptr->isn_arg.loadstore.ls_sid); |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2121 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
|
2122 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
|
2123 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2124 if (di == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2125 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
2126 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
|
2127 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
|
2128 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
|
2129 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2130 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2131 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2132 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
|
2133 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 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
|
2135 ++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
|
2136 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 |
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
|
2140 // 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
|
2141 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
|
2142 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
|
2143 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
|
2144 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
|
2145 { |
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
|
2146 dictitem_T *di = NULL; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2147 hashtab_T *ht = NULL; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2148 char namespace; |
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
|
2149 |
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
|
2150 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
|
2151 { |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2152 case ISN_LOADG: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2153 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
|
2154 namespace = 'g'; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2155 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
|
2156 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
|
2157 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
|
2158 namespace = 'b'; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2159 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
|
2160 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
|
2161 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
|
2162 namespace = 'w'; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2163 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
|
2164 case ISN_LOADT: |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2165 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
|
2166 namespace = 't'; |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2167 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
|
2168 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
|
2169 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
|
2170 } |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2171 di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 if (di == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
2175 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
|
2176 semsg(_(e_undefined_variable_char_str), |
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
|
2177 namespace, iptr->isn_arg.string); |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
2178 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
|
2179 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2181 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2182 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
|
2183 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2184 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
|
2185 ++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
|
2186 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2187 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2190 // load autoload variable |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2191 case ISN_LOADAUTO: |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2192 { |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2193 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
|
2194 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2195 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
|
2196 goto theend; |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2197 SOURCING_LNUM = iptr->isn_lnum; |
23454
5e6a5ccf5dcb
patch 8.2.2270: warning for size_t to int conversion
Bram Moolenaar <Bram@vim.org>
parents:
23450
diff
changeset
|
2198 if (eval_variable(name, (int)STRLEN(name), |
24112
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
2199 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
|
2200 goto on_error; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2201 ++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
|
2202 } |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2203 break; |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2204 |
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
|
2205 // 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
|
2206 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
|
2207 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
|
2208 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
|
2209 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
|
2210 { |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2211 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
|
2212 |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2213 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
|
2214 { |
21401
aa7675a4a0cd
patch 8.2.1251: Vim9: warning for pointer usage, test failure undetected
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
2215 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
|
2216 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
|
2217 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
|
2218 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
|
2219 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
|
2220 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
|
2221 } |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2222 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
|
2223 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
|
2224 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
|
2225 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
|
2226 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
|
2227 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
|
2228 ++d->dv_refcount; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2229 ++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
|
2230 } |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2231 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
|
2232 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 // load &option |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 case ISN_LOADOPT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2236 typval_T optval; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 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
|
2238 |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
2239 // 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
|
2240 // 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
|
2241 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
|
2242 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
|
2243 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
|
2244 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 *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
|
2246 ++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
|
2247 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 // load $ENV |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 case ISN_LOADENV: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 typval_T optval; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 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
|
2255 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2256 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
|
2257 goto theend; |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
2258 // 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
|
2259 (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
|
2260 *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
|
2261 ++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
|
2262 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2263 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2264 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2265 // load @register |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2266 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
|
2267 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
|
2268 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2269 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
|
2270 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
|
2271 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
|
2272 // 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
|
2273 // empty string. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2274 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
|
2275 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
|
2276 ++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
|
2277 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2278 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2279 // store local variable |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2280 case ISN_STORE: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2281 --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
|
2282 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
|
2283 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2284 *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
|
2285 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2286 |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2287 // store s: variable in old script |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2288 case ISN_STORES: |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2289 { |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2290 hashtab_T *ht = &SCRIPT_VARS( |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2291 iptr->isn_arg.loadstore.ls_sid); |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2292 char_u *name = iptr->isn_arg.loadstore.ls_name; |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
2293 dictitem_T *di = find_var_in_ht(ht, 0, name + 2, TRUE); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2294 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2295 --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
|
2296 if (di == NULL) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
2297 store_var(name, STACK_TV_BOT(0)); |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
2298 else |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2299 { |
24305
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2300 SOURCING_LNUM = iptr->isn_lnum; |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2301 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
|
2302 { |
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
2303 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
|
2304 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
|
2305 } |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
2306 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
|
2307 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
|
2308 } |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2309 } |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2310 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2311 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2312 // 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
|
2313 case ISN_STORESCRIPT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2314 { |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
2315 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
|
2316 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
|
2317 |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
2318 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
|
2319 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
|
2320 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2321 --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
|
2322 |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2323 // "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
|
2324 // 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
|
2325 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
|
2326 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
|
2327 { |
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
2328 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
|
2329 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
|
2330 } |
24303
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2331 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 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
|
2333 *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
|
2334 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2335 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2336 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2337 // store option |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2338 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
|
2339 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
|
2340 { |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
2341 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
|
2342 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
|
2343 long n = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2344 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
|
2345 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
|
2346 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
|
2347 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
|
2348 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2349 --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
|
2350 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
|
2351 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
|
2352 { |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 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
|
2354 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
|
2355 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
|
2356 } |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
2357 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
|
2358 { |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
2359 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
|
2360 // 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
|
2361 // 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
|
2362 // 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
|
2363 // 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
|
2364 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
|
2365 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
|
2366 { |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
2367 clear_tv(tv); |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
2368 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
|
2369 } |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26445
diff
changeset
|
2370 } |
20419
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
2371 else |
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
2372 // 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
|
2373 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
|
2374 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
|
2375 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
|
2376 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
|
2377 if (msg != NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2378 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
2379 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
|
2380 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
|
2381 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
|
2382 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2384 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2385 |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2386 // store $ENV |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2387 case ISN_STOREENV: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2388 --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
|
2389 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
|
2390 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
|
2391 clear_tv(tv); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2392 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2393 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2394 // store @r |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2395 case ISN_STOREREG: |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2396 { |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2397 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
|
2398 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2399 --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
|
2400 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
|
2401 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
|
2402 clear_tv(tv); |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2403 } |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2404 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2405 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2406 // store v: variable |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2407 case ISN_STOREV: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2408 --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
|
2409 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
|
2410 == 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
|
2411 // 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
|
2412 goto on_error; |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2413 break; |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
2414 |
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
|
2415 // 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
|
2416 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
|
2417 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
|
2418 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
|
2419 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
|
2420 { |
23295
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
2421 dictitem_T *di; |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
2422 hashtab_T *ht; |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
2423 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
|
2424 |
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
|
2425 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
|
2426 { |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
2427 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
|
2428 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
|
2429 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
|
2430 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
|
2431 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
|
2432 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
|
2433 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
|
2434 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
|
2435 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
|
2436 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
|
2437 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
|
2438 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
|
2439 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
|
2440 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
|
2441 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2442 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2443 --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
|
2444 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
|
2445 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
|
2446 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
|
2447 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2448 { |
23295
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
2449 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
|
2450 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
|
2451 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
|
2452 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
|
2453 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
|
2454 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2455 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2456 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2457 |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2458 // 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
|
2459 case ISN_STOREAUTO: |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2460 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
|
2461 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
|
2462 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
|
2463 --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
|
2464 break; |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
2465 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2466 // 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
|
2467 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
|
2468 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
|
2469 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2470 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
|
2471 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
|
2472 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2473 |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2474 // 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
|
2475 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
|
2476 { |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2477 vartype_T dest_type = iptr->isn_arg.vartype; |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2478 typval_T *tv_idx = STACK_TV_BOT(-2); |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2479 typval_T *tv_dest = STACK_TV_BOT(-1); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2480 int status = OK; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2481 |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2482 // Stack contains: |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2483 // -3 value to be stored |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2484 // -2 index |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2485 // -1 dict or list |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2486 tv = STACK_TV_BOT(-3); |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
2487 SOURCING_LNUM = iptr->isn_lnum; |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2488 if (dest_type == VAR_ANY) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2489 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2490 dest_type = tv_dest->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
|
2491 if (dest_type == VAR_DICT) |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
2492 status = do_2string(tv_idx, TRUE, FALSE); |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2493 else if (dest_type == VAR_LIST |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2494 && tv_idx->v_type != 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
|
2495 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2496 emsg(_(e_number_expected)); |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2497 status = FAIL; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2498 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2499 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2500 else if (dest_type != tv_dest->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
|
2501 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2502 // just in case, should be OK |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2503 semsg(_(e_expected_str_but_got_str), |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2504 vartype_name(dest_type), |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2505 vartype_name(tv_dest->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
|
2506 status = FAIL; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2507 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2508 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2509 if (status == OK && dest_type == VAR_LIST) |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2510 { |
23650
83a69ada0274
patch 8.2.2367: test failures on some less often used systems
Bram Moolenaar <Bram@vim.org>
parents:
23628
diff
changeset
|
2511 long lidx = (long)tv_idx->vval.v_number; |
83a69ada0274
patch 8.2.2367: test failures on some less often used systems
Bram Moolenaar <Bram@vim.org>
parents:
23628
diff
changeset
|
2512 list_T *list = tv_dest->vval.v_list; |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2513 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2514 if (list == NULL) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2515 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2516 emsg(_(e_list_not_set)); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2517 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2518 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2519 if (lidx < 0 && list->lv_len + lidx >= 0) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2520 // negative index is relative to the end |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2521 lidx = list->lv_len + lidx; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2522 if (lidx < 0 || lidx > list->lv_len) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2523 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2524 semsg(_(e_listidx), lidx); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2525 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2526 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2527 if (lidx < list->lv_len) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2528 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2529 listitem_T *li = list_find(list, lidx); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2530 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2531 if (error_if_locked(li->li_tv.v_lock, |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2532 e_cannot_change_list_item)) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2533 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2534 // overwrite existing list item |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2535 clear_tv(&li->li_tv); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2536 li->li_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
|
2537 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2538 else |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2539 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2540 if (error_if_locked(list->lv_lock, |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2541 e_cannot_change_list)) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2542 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2543 // append to list, only fails when out of memory |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2544 if (list_append_tv(list, tv) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2545 goto theend; |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2546 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
|
2547 } |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2548 } |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2549 else if (status == OK && dest_type == VAR_DICT) |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2550 { |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2551 char_u *key = tv_idx->vval.v_string; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2552 dict_T *dict = tv_dest->vval.v_dict; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2553 dictitem_T *di; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2554 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2555 SOURCING_LNUM = iptr->isn_lnum; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2556 if (dict == NULL) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2557 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2558 emsg(_(e_dictionary_not_set)); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2559 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2560 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2561 if (key == NULL) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2562 key = (char_u *)""; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2563 di = dict_find(dict, key, -1); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2564 if (di != NULL) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2565 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2566 if (error_if_locked(di->di_tv.v_lock, |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2567 e_cannot_change_dict_item)) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2568 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2569 // overwrite existing value |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2570 clear_tv(&di->di_tv); |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2571 di->di_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
|
2572 } |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2573 else |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2574 { |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2575 if (error_if_locked(dict->dv_lock, |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2576 e_cannot_change_dict)) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2577 goto on_error; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2578 // add to dict, only fails when out of memory |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2579 if (dict_add_tv(dict, (char *)key, tv) == FAIL) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
2580 goto theend; |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2581 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
|
2582 } |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2583 } |
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
|
2584 else if (status == OK && dest_type == VAR_BLOB) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2585 { |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2586 long lidx = (long)tv_idx->vval.v_number; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2587 blob_T *blob = tv_dest->vval.v_blob; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2588 varnumber_T nr; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2589 int error = FALSE; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2590 int len; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2591 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2592 if (blob == NULL) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2593 { |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2594 emsg(_(e_blob_not_set)); |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2595 goto on_error; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2596 } |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2597 len = blob_len(blob); |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2598 if (lidx < 0 && len + lidx >= 0) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2599 // negative index is relative to the end |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2600 lidx = len + lidx; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2601 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2602 // Can add one byte at the end. |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2603 if (lidx < 0 || lidx > len) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2604 { |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2605 semsg(_(e_blobidx), lidx); |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2606 goto on_error; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2607 } |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2608 if (value_check_lock(blob->bv_lock, |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2609 (char_u *)"blob", FALSE)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2610 goto on_error; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2611 nr = tv_get_number_chk(tv, &error); |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2612 if (error) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2613 goto on_error; |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
2614 blob_set_append(blob, lidx, nr); |
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
|
2615 } |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2616 else |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2617 { |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2618 status = FAIL; |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2619 semsg(_(e_cannot_index_str), vartype_name(dest_type)); |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2620 } |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2621 |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2622 clear_tv(tv_idx); |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2623 clear_tv(tv_dest); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2624 ectx->ec_stack.ga_len -= 3; |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2625 if (status == 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
|
2626 { |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23254
diff
changeset
|
2627 clear_tv(tv); |
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
|
2628 goto on_error; |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
2629 } |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2630 } |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2631 break; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
2632 |
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
|
2633 // store value in blob range |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2634 case ISN_STORERANGE: |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2635 { |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2636 typval_T *tv_idx1 = STACK_TV_BOT(-3); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2637 typval_T *tv_idx2 = STACK_TV_BOT(-2); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2638 typval_T *tv_dest = STACK_TV_BOT(-1); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2639 int status = OK; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2640 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2641 // Stack contains: |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2642 // -4 value to be stored |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2643 // -3 first index or "none" |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2644 // -2 second index or "none" |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2645 // -1 destination list or blob |
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
|
2646 tv = STACK_TV_BOT(-4); |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2647 if (tv_dest->v_type == VAR_LIST) |
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
|
2648 { |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2649 long n1; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2650 long n2; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2651 int error = FALSE; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2652 |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2653 SOURCING_LNUM = iptr->isn_lnum; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2654 n1 = (long)tv_get_number_chk(tv_idx1, &error); |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2655 if (error) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2656 status = FAIL; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2657 else |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2658 { |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2659 if (tv_idx2->v_type == VAR_SPECIAL |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2660 && tv_idx2->vval.v_number == VVAL_NONE) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2661 n2 = list_len(tv_dest->vval.v_list) - 1; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2662 else |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2663 n2 = (long)tv_get_number_chk(tv_idx2, &error); |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2664 if (error) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2665 status = FAIL; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2666 else |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2667 { |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2668 listitem_T *li1 = check_range_index_one( |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2669 tv_dest->vval.v_list, &n1, FALSE); |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2670 |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2671 if (li1 == NULL) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2672 status = FAIL; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2673 else |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2674 { |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2675 status = check_range_index_two( |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2676 tv_dest->vval.v_list, |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2677 &n1, li1, &n2, FALSE); |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2678 if (status != FAIL) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2679 status = list_assign_range( |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2680 tv_dest->vval.v_list, |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2681 tv->vval.v_list, |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2682 n1, |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2683 n2, |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2684 tv_idx2->v_type == VAR_SPECIAL, |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2685 (char_u *)"=", |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2686 (char_u *)"[unknown]"); |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2687 } |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2688 } |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2689 } |
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
|
2690 } |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2691 else if (tv_dest->v_type == VAR_BLOB) |
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
|
2692 { |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2693 varnumber_T n1; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2694 varnumber_T n2; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2695 int error = FALSE; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2696 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2697 n1 = tv_get_number_chk(tv_idx1, &error); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2698 if (error) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2699 status = FAIL; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2700 else |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2701 { |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2702 if (tv_idx2->v_type == VAR_SPECIAL |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2703 && tv_idx2->vval.v_number == VVAL_NONE) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2704 n2 = blob_len(tv_dest->vval.v_blob) - 1; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2705 else |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2706 n2 = tv_get_number_chk(tv_idx2, &error); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2707 if (error) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2708 status = FAIL; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2709 else |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2710 { |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2711 long bloblen = blob_len(tv_dest->vval.v_blob); |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2712 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2713 if (check_blob_index(bloblen, |
24454
53216e87f21c
patch 8.2.2767: compiler warning for unused argument
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
2714 n1, FALSE) == FAIL |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2715 || check_blob_range(bloblen, |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2716 n1, n2, FALSE) == FAIL) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2717 status = FAIL; |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2718 else |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2719 status = blob_set_range( |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2720 tv_dest->vval.v_blob, n1, n2, tv); |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
2721 } |
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
|
2722 } |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2723 } |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2724 else |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2725 { |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2726 status = FAIL; |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2727 emsg(_(e_blob_required)); |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
2728 } |
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
|
2729 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2730 clear_tv(tv_idx1); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2731 clear_tv(tv_idx2); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2732 clear_tv(tv_dest); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2733 ectx->ec_stack.ga_len -= 4; |
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
|
2734 clear_tv(tv); |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2735 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2736 if (status == FAIL) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2737 goto on_error; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2738 } |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2739 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
|
2740 |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2741 // load or store variable or argument from outer scope |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2742 case ISN_LOADOUTER: |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2743 case ISN_STOREOUTER: |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2744 { |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2745 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
|
2746 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
|
2747 : 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
|
2748 |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2749 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
|
2750 { |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2751 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
|
2752 --depth; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2753 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2754 if (outer == NULL) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2755 { |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2756 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
|
2757 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
|
2758 || 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
|
2759 // 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
|
2760 // context. |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
2761 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
|
2762 else |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26370
diff
changeset
|
2763 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
|
2764 goto theend; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2765 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2766 tv = ((typval_T *)outer->out_stack->ga_data) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2767 + outer->out_frame_idx + STACK_FRAME_SIZE |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2768 + iptr->isn_arg.outer.outer_idx; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2769 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
|
2770 { |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
2771 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
|
2772 goto theend; |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2773 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
|
2774 ++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
|
2775 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2776 else |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2777 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2778 --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
|
2779 clear_tv(tv); |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2780 *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
|
2781 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2782 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2783 break; |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
2784 |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2785 // 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
|
2786 case ISN_UNLETINDEX: |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2787 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2788 typval_T *tv_idx = STACK_TV_BOT(-2); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2789 typval_T *tv_dest = STACK_TV_BOT(-1); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2790 int status = OK; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2791 |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2792 // Stack contains: |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2793 // -2 index |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2794 // -1 dict or list |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2795 if (tv_dest->v_type == VAR_DICT) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2796 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2797 // unlet a dict item, index must be a string |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2798 if (tv_idx->v_type != VAR_STRING) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2799 { |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2800 SOURCING_LNUM = iptr->isn_lnum; |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2801 semsg(_(e_expected_str_but_got_str), |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2802 vartype_name(VAR_STRING), |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2803 vartype_name(tv_idx->v_type)); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2804 status = FAIL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2805 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2806 else |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2807 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2808 dict_T *d = tv_dest->vval.v_dict; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2809 char_u *key = tv_idx->vval.v_string; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2810 dictitem_T *di = NULL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2811 |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2812 if (key == NULL) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2813 key = (char_u *)""; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2814 if (d != NULL) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2815 di = dict_find(d, key, (int)STRLEN(key)); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2816 if (di == NULL) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2817 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2818 // NULL dict is equivalent to empty dict |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2819 SOURCING_LNUM = iptr->isn_lnum; |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2820 semsg(_(e_dictkey), key); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2821 status = FAIL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2822 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2823 else |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2824 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2825 // TODO: check for dict or item locked |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2826 dictitem_remove(d, di); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2827 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2828 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2829 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2830 else if (tv_dest->v_type == VAR_LIST) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2831 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2832 // unlet a List item, index must be a number |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2833 SOURCING_LNUM = iptr->isn_lnum; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2834 if (check_for_number(tv_idx) == FAIL) |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2835 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2836 status = FAIL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2837 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2838 else |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2839 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2840 list_T *l = tv_dest->vval.v_list; |
23650
83a69ada0274
patch 8.2.2367: test failures on some less often used systems
Bram Moolenaar <Bram@vim.org>
parents:
23628
diff
changeset
|
2841 long n = (long)tv_idx->vval.v_number; |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2842 listitem_T *li = NULL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2843 |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2844 li = list_find(l, n); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2845 if (li == NULL) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2846 { |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2847 SOURCING_LNUM = iptr->isn_lnum; |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2848 semsg(_(e_listidx), n); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2849 status = FAIL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2850 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2851 else |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2852 // TODO: check for list or item locked |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2853 listitem_remove(l, li); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2854 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2855 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2856 else |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2857 { |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2858 status = FAIL; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2859 semsg(_(e_cannot_index_str), |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2860 vartype_name(tv_dest->v_type)); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2861 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2862 |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2863 clear_tv(tv_idx); |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2864 clear_tv(tv_dest); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2865 ectx->ec_stack.ga_len -= 2; |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2866 if (status == FAIL) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2867 goto on_error; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2868 } |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2869 break; |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2870 |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2871 // 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
|
2872 case ISN_UNLETRANGE: |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2873 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2874 // Stack contains: |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2875 // -3 index1 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2876 // -2 index2 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2877 // -1 dict or list |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2878 typval_T *tv_idx1 = STACK_TV_BOT(-3); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2879 typval_T *tv_idx2 = STACK_TV_BOT(-2); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2880 typval_T *tv_dest = STACK_TV_BOT(-1); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2881 int status = OK; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2882 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2883 if (tv_dest->v_type == VAR_LIST) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2884 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2885 // indexes must be a number |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2886 SOURCING_LNUM = iptr->isn_lnum; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2887 if (check_for_number(tv_idx1) == FAIL |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2888 || (tv_idx2->v_type != VAR_SPECIAL |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2889 && check_for_number(tv_idx2) == FAIL)) |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2890 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2891 status = FAIL; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2892 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2893 else |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2894 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2895 list_T *l = tv_dest->vval.v_list; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2896 long n1 = (long)tv_idx1->vval.v_number; |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2897 long n2 = tv_idx2->v_type == VAR_SPECIAL |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2898 ? 0 : (long)tv_idx2->vval.v_number; |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2899 listitem_T *li; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2900 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2901 li = list_find_index(l, &n1); |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2902 if (li == NULL) |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2903 status = FAIL; |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2904 else |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2905 { |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2906 if (n1 < 0) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2907 n1 = list_idx_of_item(l, li); |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2908 if (n2 < 0) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2909 { |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2910 listitem_T *li2 = list_find(l, n2); |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2911 |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2912 if (li2 == NULL) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2913 status = FAIL; |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2914 else |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2915 n2 = list_idx_of_item(l, li2); |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2916 } |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2917 if (status != FAIL |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2918 && tv_idx2->v_type != VAR_SPECIAL |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2919 && n2 < n1) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2920 { |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2921 semsg(_(e_listidx), n2); |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2922 status = FAIL; |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2923 } |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25326
diff
changeset
|
2924 if (status != FAIL |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2925 && list_unlet_range(l, li, NULL, n1, |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2926 tv_idx2->v_type != VAR_SPECIAL, n2) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2927 == FAIL) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2928 status = FAIL; |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2929 } |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2930 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2931 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2932 else |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2933 { |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2934 status = FAIL; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2935 SOURCING_LNUM = iptr->isn_lnum; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2936 semsg(_(e_cannot_index_str), |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2937 vartype_name(tv_dest->v_type)); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2938 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2939 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2940 clear_tv(tv_idx1); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2941 clear_tv(tv_idx2); |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2942 clear_tv(tv_dest); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
2943 ectx->ec_stack.ga_len -= 3; |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2944 if (status == FAIL) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2945 goto on_error; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2946 } |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2947 break; |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23976
diff
changeset
|
2948 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2949 // push constant |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2950 case ISN_PUSHNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2951 case ISN_PUSHBOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2952 case ISN_PUSHSPEC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2953 case ISN_PUSHF: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2954 case ISN_PUSHS: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2955 case ISN_PUSHBLOB: |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2956 case ISN_PUSHFUNC: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2957 case ISN_PUSHCHANNEL: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2958 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
|
2959 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
|
2960 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2961 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
|
2962 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
|
2963 ++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
|
2964 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
|
2965 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2966 case ISN_PUSHNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2967 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
|
2968 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
|
2969 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2970 case ISN_PUSHBOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2971 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
|
2972 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
|
2973 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2974 case ISN_PUSHSPEC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2975 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
|
2976 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
|
2977 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2978 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2979 case ISN_PUSHF: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2980 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
|
2981 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
|
2982 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2983 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2984 case ISN_PUSHBLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 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
|
2986 break; |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2987 case ISN_PUSHFUNC: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2988 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
|
2989 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
|
2990 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
|
2991 else |
ec1eeb1b69e2
patch 8.2.0340: Vim9: function and partial types not tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
2992 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
|
2993 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
|
2994 break; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2995 case ISN_PUSHCHANNEL: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2996 #ifdef FEAT_JOB_CHANNEL |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2997 tv->v_type = VAR_CHANNEL; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2998 tv->vval.v_channel = iptr->isn_arg.channel; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
2999 if (tv->vval.v_channel != NULL) |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3000 ++tv->vval.v_channel->ch_refcount; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3001 #endif |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3002 break; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3003 case ISN_PUSHJOB: |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3004 #ifdef FEAT_JOB_CHANNEL |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3005 tv->v_type = VAR_JOB; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3006 tv->vval.v_job = iptr->isn_arg.job; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3007 if (tv->vval.v_job != NULL) |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3008 ++tv->vval.v_job->jv_refcount; |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3009 #endif |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19538
diff
changeset
|
3010 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3011 default: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3012 tv->v_type = VAR_STRING; |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
3013 tv->vval.v_string = vim_strsave( |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
3014 iptr->isn_arg.string == NULL |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
3015 ? (char_u *)"" : 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
|
3016 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3017 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3018 |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3019 case ISN_UNLET: |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3020 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
|
3021 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
|
3022 goto on_error; |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3023 break; |
20099
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
3024 case ISN_UNLETENV: |
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
3025 vim_unsetenv(iptr->isn_arg.unlet.ul_name); |
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
3026 break; |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3027 |
25605
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3028 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
|
3029 { |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3030 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
|
3031 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
|
3032 |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3033 // 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
|
3034 // 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
|
3035 --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
|
3036 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
|
3037 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
|
3038 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
|
3039 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
|
3040 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
|
3041 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
|
3042 } |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3043 break; |
6f13d9ea0d04
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
3044 |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3045 case ISN_LOCKCONST: |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3046 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
|
3047 break; |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
3048 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3049 // 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
|
3050 // 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
|
3051 case ISN_NEWLIST: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3052 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
|
3053 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3054 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3055 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3056 // 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
|
3057 case ISN_NEWDICT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3058 { |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3059 int count = iptr->isn_arg.number; |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3060 dict_T *dict = dict_alloc(); |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3061 dictitem_T *item; |
22808
96dbb61a54c2
patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
3062 char_u *key; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3063 int idx; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3064 |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3065 if (unlikely(dict == NULL)) |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3066 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3067 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
|
3068 { |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3069 // have already checked key type is VAR_STRING |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3070 tv = STACK_TV_BOT(2 * (idx - count)); |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3071 // check key is unique |
22808
96dbb61a54c2
patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
3072 key = tv->vval.v_string == NULL |
96dbb61a54c2
patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
3073 ? (char_u *)"" : tv->vval.v_string; |
96dbb61a54c2
patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
3074 item = dict_find(dict, key, -1); |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3075 if (item != NULL) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3076 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
3077 SOURCING_LNUM = iptr->isn_lnum; |
22808
96dbb61a54c2
patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
3078 semsg(_(e_duplicate_key), key); |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3079 dict_unref(dict); |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3080 goto on_error; |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3081 } |
22808
96dbb61a54c2
patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
3082 item = dictitem_alloc(key); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3083 clear_tv(tv); |
25350
0c5b84c5862a
patch 8.2.3212: Vim9: execution speed can be improved
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3084 if (unlikely(item == NULL)) |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3085 { |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3086 dict_unref(dict); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3087 goto theend; |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3088 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3089 item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3090 item->di_tv.v_lock = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3091 if (dict_add(dict, item) == 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
|
3092 { |
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
|
3093 // can this ever happen? |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3094 dict_unref(dict); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3095 goto theend; |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
3096 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3097 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3098 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3099 if (count > 0) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3100 ectx->ec_stack.ga_len -= 2 * 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
|
3101 else 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
|
3102 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3103 else |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3104 ++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
|
3105 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
|
3106 tv->v_type = VAR_DICT; |
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
|
3107 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
|
3108 tv->vval.v_dict = dict; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3109 ++dict->dv_refcount; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3110 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3111 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3112 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3113 // 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
|
3114 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
|
3115 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
|
3116 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
|
3117 NULL, |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
3118 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
|
3119 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
|
3120 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
|
3121 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3122 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3123 // 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
|
3124 case ISN_BCALL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3125 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
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3131 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3132 // 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
|
3133 case ISN_PCALL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3135 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
|
3136 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
|
3137 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
|
3138 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3139 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
|
3140 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
|
3141 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3142 // 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
|
3143 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
|
3144 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3145 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3146 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3147 // 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
|
3148 --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
|
3149 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
|
3150 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
|
3151 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3152 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
|
3153 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
|
3154 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
|
3155 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
|
3156 goto on_error; |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3157 } |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3158 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3159 |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3160 case ISN_PCALL_END: |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3161 // 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
|
3162 // 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
|
3163 // 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
|
3164 --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
|
3165 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
|
3166 *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
|
3167 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3168 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3169 // 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
|
3170 case ISN_UCALL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3171 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3172 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
|
3173 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3174 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
|
3175 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
|
3176 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
|
3177 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
|
3178 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3179 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3180 |
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
|
3181 // 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
|
3182 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
|
3183 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
|
3184 goto theend; |
23543
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
3185 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
|
3186 ++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
|
3187 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
|
3188 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
|
3189 tv->v_lock = 0; |
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
3190 // FALLTHROUGH |
f90e429453fd
patch 8.2.2314: Vim9: returning zero takes two instructions
Bram Moolenaar <Bram@vim.org>
parents:
23541
diff
changeset
|
3191 |
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
|
3192 // 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
|
3193 case ISN_RETURN: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3194 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3195 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
|
3196 trycmd_T *trycmd = NULL; |
19221
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
3197 |
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
3198 if (trystack->ga_len > 0) |
f63f3b423ad3
patch 8.2.0169: Coverity warning for dead code
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
3199 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
|
3200 + trystack->ga_len - 1; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
3201 if (trycmd != NULL |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3202 && 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
|
3203 { |
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
|
3204 // 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
|
3205 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
|
3206 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
|
3207 else |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3208 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
|
3209 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
|
3210 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3211 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
|
3212 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
|
3213 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3214 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3215 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
3216 // 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
|
3217 case ISN_FUNCREF: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3218 { |
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
|
3219 partial_T *pt = ALLOC_CLEAR_ONE(partial_T); |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3220 ufunc_T *ufunc; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3221 funcref_T *funcref = &iptr->isn_arg.funcref; |
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
|
3222 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3223 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
|
3224 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
|
3225 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
|
3226 { |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
3227 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
|
3228 goto theend; |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
3229 } |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3230 if (funcref->fr_func_name == NULL) |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3231 { |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3232 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
|
3233 + 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
|
3234 |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3235 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
|
3236 } |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3237 else |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3238 { |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3239 ufunc = find_func(funcref->fr_func_name, FALSE, NULL); |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3240 } |
26325
c189c40c9a22
patch 8.2.3693: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
3241 if (ufunc == NULL) |
c189c40c9a22
patch 8.2.3693: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
3242 { |
c189c40c9a22
patch 8.2.3693: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
3243 SOURCING_LNUM = iptr->isn_lnum; |
c189c40c9a22
patch 8.2.3693: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
3244 emsg(_(e_function_reference_invalid)); |
c189c40c9a22
patch 8.2.3693: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
3245 goto theend; |
c189c40c9a22
patch 8.2.3693: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
3246 } |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
3247 if (fill_partial_and_closure(pt, ufunc, 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
|
3248 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3249 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
|
3250 ++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
|
3251 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
|
3252 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
|
3253 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
|
3254 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3255 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3256 |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
3257 // 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
|
3258 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
|
3259 { |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
3260 newfunc_T *newfunc = &iptr->isn_arg.newfunc; |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
3261 |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
3262 if (copy_func(newfunc->nf_lambda, newfunc->nf_global, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3263 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
|
3264 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
|
3265 } |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
3266 break; |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
3267 |
22973
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3268 // List functions |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3269 case ISN_DEF: |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3270 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
|
3271 list_functions(NULL); |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3272 else |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3273 { |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3274 exarg_T ea; |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3275 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3276 CLEAR_FIELD(ea); |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3277 ea.cmd = ea.arg = iptr->isn_arg.string; |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3278 define_function(&ea, NULL); |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3279 } |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3280 break; |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22952
diff
changeset
|
3281 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3282 // 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
|
3283 case ISN_JUMP: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3284 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3285 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
|
3286 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
|
3287 int jump = TRUE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3288 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3289 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
|
3290 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3291 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
|
3292 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
|
3293 || 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
|
3294 || 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
|
3295 { |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
3296 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
|
3297 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
|
3298 if (error) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
3299 goto on_error; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
3300 } |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
3301 else |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
3302 jump = tv2bool(tv); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3303 if (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
|
3304 || when == JUMP_AND_KEEP_IF_FALSE |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
3305 || 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
|
3306 jump = !jump; |
19334
61646c189622
patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19328
diff
changeset
|
3307 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
|
3308 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3309 // 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
|
3310 clear_tv(tv); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3311 --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
|
3312 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3313 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3314 if (jump) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3315 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
|
3316 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3317 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3318 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3319 // 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
|
3320 // 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
|
3321 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
|
3322 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
|
3323 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
|
3324 && !(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
|
3325 && 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
|
3326 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
|
3327 break; |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3328 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3329 // 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
|
3330 case ISN_FOR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3331 { |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3332 typval_T *ltv = STACK_TV_BOT(-1); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3333 typval_T *idxtv = |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3334 STACK_TV_VAR(iptr->isn_arg.forloop.for_idx); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3335 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3336 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
|
3337 goto theend; |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3338 if (ltv->v_type == VAR_LIST) |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3339 { |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3340 list_T *list = ltv->vval.v_list; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3341 |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3342 // push the next item from the list |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3343 ++idxtv->vval.v_number; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3344 if (list == NULL |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3345 || idxtv->vval.v_number >= list->lv_len) |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3346 { |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3347 // past the end of the list, jump to "endfor" |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3348 ectx->ec_iidx = iptr->isn_arg.forloop.for_end; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3349 may_restore_cmdmod(&ectx->ec_funclocal); |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3350 } |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3351 else if (list->lv_first == &range_list_item) |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3352 { |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3353 // non-materialized range() list |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3354 tv = STACK_TV_BOT(0); |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3355 tv->v_type = VAR_NUMBER; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3356 tv->v_lock = 0; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3357 tv->vval.v_number = list_find_nr( |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3358 list, idxtv->vval.v_number, NULL); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3359 ++ectx->ec_stack.ga_len; |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3360 } |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3361 else |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3362 { |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3363 listitem_T *li = list_find(list, |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3364 idxtv->vval.v_number); |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3365 |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3366 copy_tv(&li->li_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
|
3367 ++ectx->ec_stack.ga_len; |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3368 } |
24220
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3369 } |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3370 else if (ltv->v_type == VAR_STRING) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 { |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3372 char_u *str = ltv->vval.v_string; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3373 |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3374 // The index is for the last byte of the previous |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3375 // character. |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3376 ++idxtv->vval.v_number; |
24392
79fda175df83
patch 8.2.2736: Vim9: for loop over string is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
3377 if (str == NULL || str[idxtv->vval.v_number] == NUL) |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3378 { |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3379 // past the end of the string, jump to "endfor" |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3380 ectx->ec_iidx = iptr->isn_arg.forloop.for_end; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3381 may_restore_cmdmod(&ectx->ec_funclocal); |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3382 } |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3383 else |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3384 { |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3385 int clen = mb_ptr2len(str + idxtv->vval.v_number); |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3386 |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3387 // Push the next character from the string. |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3388 tv = STACK_TV_BOT(0); |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3389 tv->v_type = VAR_STRING; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3390 tv->vval.v_string = vim_strnsave( |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3391 str + idxtv->vval.v_number, clen); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3392 ++ectx->ec_stack.ga_len; |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3393 idxtv->vval.v_number += clen - 1; |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3394 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3395 } |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3396 else if (ltv->v_type == VAR_BLOB) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3397 { |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3398 blob_T *blob = ltv->vval.v_blob; |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3399 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3400 // When we get here the first time make a copy of the |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3401 // blob, so that the iteration still works when it is |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3402 // changed. |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3403 if (idxtv->vval.v_number == -1 && blob != NULL) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3404 { |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3405 blob_copy(blob, ltv); |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3406 blob_unref(blob); |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3407 blob = ltv->vval.v_blob; |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3408 } |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3409 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3410 // The index is for the previous byte. |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3411 ++idxtv->vval.v_number; |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3412 if (blob == NULL |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3413 || idxtv->vval.v_number >= blob_len(blob)) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3414 { |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3415 // past the end of the blob, jump to "endfor" |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3416 ectx->ec_iidx = iptr->isn_arg.forloop.for_end; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3417 may_restore_cmdmod(&ectx->ec_funclocal); |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3418 } |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3419 else |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3420 { |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3421 // Push the next byte from the blob. |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3422 tv = STACK_TV_BOT(0); |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3423 tv->v_type = VAR_NUMBER; |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3424 tv->vval.v_number = blob_get(blob, |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3425 idxtv->vval.v_number); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3426 ++ectx->ec_stack.ga_len; |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3427 } |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
3428 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3429 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3430 { |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3431 semsg(_(e_for_loop_on_str_not_supported), |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24226
diff
changeset
|
3432 vartype_name(ltv->v_type)); |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
3433 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3434 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3435 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3436 break; |
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 // 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
|
3439 case ISN_TRY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3440 { |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
3441 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
|
3442 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3443 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
|
3444 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3445 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
|
3446 + 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
|
3447 ++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
|
3448 ++trylevel; |
23934
f9a4ede76237
patch 8.2.2509: tests fail on s390 build
Bram Moolenaar <Bram@vim.org>
parents:
23927
diff
changeset
|
3449 CLEAR_POINTER(trycmd); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3450 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
|
3451 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
|
3452 trycmd->tcd_catch_idx = |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3453 iptr->isn_arg.try.try_ref->try_catch; |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3454 trycmd->tcd_finally_idx = |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3455 iptr->isn_arg.try.try_ref->try_finally; |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3456 trycmd->tcd_endtry_idx = |
a7a9176bb542
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
3457 iptr->isn_arg.try.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
|
3458 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3459 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3460 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3461 case ISN_PUSHEXC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3462 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
|
3463 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
3464 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
|
3465 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
|
3466 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3467 } |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
3468 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
|
3469 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3470 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
|
3471 ++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
|
3472 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
|
3473 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
|
3474 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
|
3475 (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
|
3476 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3477 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3478 case ISN_CATCH: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3479 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3480 garray_T *trystack = &ectx->ec_trystack; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3481 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3482 may_restore_cmdmod(&ectx->ec_funclocal); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3483 if (trystack->ga_len > 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3484 { |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
3485 trycmd_T *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
|
3486 + trystack->ga_len - 1; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3487 trycmd->tcd_caught = TRUE; |
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
|
3488 trycmd->tcd_did_throw = FALSE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3489 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3490 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
|
3491 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
|
3492 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
|
3493 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3494 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3495 |
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
|
3496 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
|
3497 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3498 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
|
3499 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
|
3500 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
|
3501 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
|
3502 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
|
3503 |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3504 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
|
3505 { |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3506 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
|
3507 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
|
3508 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
|
3509 } |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3510 // 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
|
3511 // :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
|
3512 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
|
3513 { |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3514 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
|
3515 + 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
|
3516 // 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
|
3517 // 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
|
3518 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
|
3519 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
|
3520 ? 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
|
3521 } |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3522 // 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
|
3523 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
|
3524 } |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3525 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
|
3526 |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
3527 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
|
3528 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3529 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
|
3530 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
|
3531 + 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
|
3532 |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
3533 // 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
|
3534 // again. |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
3535 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
|
3536 break; |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
3537 } |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
3538 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3539 // 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
|
3540 case ISN_ENDTRY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3541 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3542 garray_T *trystack = &ectx->ec_trystack; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3543 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3544 if (trystack->ga_len > 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3545 { |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3546 trycmd_T *trycmd; |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19635
diff
changeset
|
3547 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3548 --trystack->ga_len; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3549 --trylevel; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3550 trycmd = ((trycmd_T *)trystack->ga_data) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3551 + trystack->ga_len; |
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
|
3552 if (trycmd->tcd_did_throw) |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
3553 did_throw = TRUE; |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
3554 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
|
3555 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3556 // discard the exception |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3557 if (caught_stack == current_exception) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3558 caught_stack = caught_stack->caught; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3559 discard_current_exception(); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3560 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3561 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3562 if (trycmd->tcd_return) |
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
|
3563 goto func_return; |
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
|
3564 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3565 while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len) |
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
|
3566 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3567 --ectx->ec_stack.ga_len; |
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
|
3568 clear_tv(STACK_TV_BOT(0)); |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23917
diff
changeset
|
3569 } |
23934
f9a4ede76237
patch 8.2.2509: tests fail on s390 build
Bram Moolenaar <Bram@vim.org>
parents:
23927
diff
changeset
|
3570 if (trycmd->tcd_cont != 0) |
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
|
3571 // handling :continue: jump to outer try block or |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3572 // start of the loop |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3573 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
|
3574 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3575 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3576 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3577 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3578 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
|
3579 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3580 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
|
3581 |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3582 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
|
3583 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3584 // 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
|
3585 // 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
|
3586 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
|
3587 clear_tv(tv); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3588 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
|
3589 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
|
3590 goto done; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3591 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3592 --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
|
3593 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
|
3594 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
|
3595 || *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
|
3596 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3597 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
|
3598 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
|
3599 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
|
3600 goto theend; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3601 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3602 |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3603 // 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
|
3604 // exception. |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3605 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
|
3606 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3607 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
|
3608 + trystack->ga_len - 1; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3609 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
|
3610 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3611 // discard the exception |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3612 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
|
3613 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
|
3614 discard_current_exception(); |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3615 trycmd->tcd_caught = FALSE; |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3616 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3617 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3618 |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3619 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
|
3620 == FAIL) |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3621 { |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3622 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
|
3623 goto theend; |
23725
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3624 } |
f98692ae09a0
patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents:
23719
diff
changeset
|
3625 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
|
3626 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3627 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3628 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3629 // 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
|
3630 case ISN_COMPAREBOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3631 case ISN_COMPARESPECIAL: |
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 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
|
3634 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
|
3635 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
|
3636 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
|
3637 int res; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3638 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3639 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
|
3640 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3641 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
|
3642 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
|
3643 default: res = 0; break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3644 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3645 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3646 --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
|
3647 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
|
3648 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
|
3649 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3650 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3651 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3652 // 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
|
3653 case ISN_OPNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3654 case ISN_COMPARENR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3655 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3656 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
|
3657 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
|
3658 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
|
3659 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
|
3660 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
|
3661 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
|
3662 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3663 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
|
3664 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3665 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
|
3666 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
|
3667 div_zero = TRUE; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3668 else |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3669 res = arg1 / arg2; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3670 break; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3671 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
|
3672 div_zero = TRUE; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3673 else |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3674 res = arg1 % arg2; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3675 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3676 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
|
3677 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
|
3678 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3679 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
|
3680 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
|
3681 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
|
3682 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
|
3683 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
|
3684 case EXPR_SEQUAL: 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
|
3685 default: break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3686 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3687 |
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; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3689 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
|
3690 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3691 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
|
3692 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
|
3693 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3694 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3695 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
|
3696 if (div_zero) |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3697 { |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3698 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
|
3699 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
|
3700 goto on_error; |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
3701 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3702 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3703 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3704 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3705 // 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
|
3706 case ISN_OPFLOAT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3707 case ISN_COMPAREFLOAT: |
19193
9f98957582d6
patch 8.2.0155: warnings from MinGW compiler; tests fail without +float
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
3708 #ifdef FEAT_FLOAT |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3709 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3710 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
|
3711 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
|
3712 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
|
3713 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
|
3714 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
|
3715 int cmp = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3716 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3717 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
|
3718 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3719 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
|
3720 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
|
3721 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
|
3722 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
|
3723 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3724 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
|
3725 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
|
3726 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
|
3727 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
|
3728 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
|
3729 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
|
3730 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
|
3731 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3732 --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
|
3733 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
|
3734 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3735 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
|
3736 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
|
3737 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3738 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3739 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
|
3740 } |
19193
9f98957582d6
patch 8.2.0155: warnings from MinGW compiler; tests fail without +float
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
3741 #endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3742 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3743 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3744 case ISN_COMPARELIST: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3745 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3746 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
|
3747 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
|
3748 list_T *arg1 = tv1->vval.v_list; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3749 list_T *arg2 = tv2->vval.v_list; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3750 int cmp = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3751 int ic = iptr->isn_arg.op.op_ic; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3752 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3753 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
|
3754 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3755 case EXPR_EQUAL: cmp = |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3756 list_equal(arg1, arg2, ic, FALSE); break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3757 case EXPR_NEQUAL: cmp = |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3758 !list_equal(arg1, arg2, ic, FALSE); break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3759 case EXPR_IS: 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
|
3760 case EXPR_ISNOT: 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
|
3761 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
|
3762 } |
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; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3764 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3765 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3766 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
|
3767 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
|
3768 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3769 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3770 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3771 case ISN_COMPAREBLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3772 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3773 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
|
3774 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
|
3775 blob_T *arg1 = tv1->vval.v_blob; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3776 blob_T *arg2 = tv2->vval.v_blob; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3777 int cmp = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3778 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3779 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
|
3780 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3781 case EXPR_EQUAL: cmp = blob_equal(arg1, arg2); break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3782 case EXPR_NEQUAL: cmp = !blob_equal(arg1, arg2); break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3783 case EXPR_IS: 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
|
3784 case EXPR_ISNOT: 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
|
3785 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
|
3786 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3787 --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
|
3788 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3789 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3790 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
|
3791 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
|
3792 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3793 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3794 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3795 // TODO: handle separately |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3796 case ISN_COMPARESTRING: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3797 case ISN_COMPAREDICT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3798 case ISN_COMPAREFUNC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3799 case ISN_COMPAREANY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3800 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3801 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
|
3802 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
|
3803 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
|
3804 int ic = iptr->isn_arg.op.op_ic; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3805 |
22262
3f082bd15d29
patch 8.2.1680: Vim9: line number for compare error is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
3806 SOURCING_LNUM = iptr->isn_lnum; |
23553
5c094273c015
patch 8.2.2319: "exptype_T" can be read as "expected type"
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
3807 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
|
3808 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3809 --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
|
3810 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3811 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3812 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3813 case ISN_ADDLIST: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3814 case ISN_ADDBLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3815 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3816 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
|
3817 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
|
3818 |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3819 // 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
|
3820 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
|
3821 { |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
3822 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
|
3823 && 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
|
3824 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
|
3825 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
|
3826 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
|
3827 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
|
3828 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3829 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3830 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
|
3831 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3832 --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
|
3833 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3834 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3835 |
22633
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3836 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
|
3837 { |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3838 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
|
3839 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
|
3840 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
|
3841 |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3842 // add an item to a list |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3843 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
|
3844 { |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3845 SOURCING_LNUM = iptr->isn_lnum; |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3846 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
|
3847 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
|
3848 } |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3849 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
|
3850 goto theend; |
22641
6dce588f7a46
patch 8.2.1869: Vim9: memory leak when using add()
Bram Moolenaar <Bram@vim.org>
parents:
22637
diff
changeset
|
3851 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3852 --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
|
3853 } |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3854 break; |
6589dae9696c
patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents:
22623
diff
changeset
|
3855 |
22637
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3856 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
|
3857 { |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3858 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
|
3859 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
|
3860 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
|
3861 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
|
3862 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
|
3863 |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3864 // 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
|
3865 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
|
3866 { |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3867 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
|
3868 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
|
3869 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
|
3870 } |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3871 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
|
3872 if (error) |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3873 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
|
3874 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
|
3875 --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
|
3876 } |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3877 break; |
4d4042683371
patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents:
22633
diff
changeset
|
3878 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3879 // 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
|
3880 case ISN_OPANY: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3881 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3882 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
|
3883 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
|
3884 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
|
3885 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3886 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
|
3887 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3888 int error = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3889 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3890 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
|
3891 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3892 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
|
3893 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3894 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
|
3895 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3896 --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
|
3897 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3898 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3899 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
|
3900 && 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
|
3901 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3902 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
|
3903 clear_tv(tv2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
3904 --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
|
3905 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3906 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3907 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3908 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3909 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
|
3910 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3911 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
|
3912 n1 = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3913 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3914 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3915 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3916 { |
23100
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3917 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
|
3918 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
|
3919 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
|
3920 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
|
3921 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3922 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
|
3923 f1 = n1; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3924 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3925 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3926 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3927 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
|
3928 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3929 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
|
3930 n2 = 0; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3931 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3932 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3933 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3934 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3935 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
|
3936 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
|
3937 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
|
3938 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3939 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
|
3940 f2 = n2; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3941 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3942 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3943 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3944 // 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
|
3945 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
|
3946 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3947 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
|
3948 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3949 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
|
3950 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
|
3951 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
|
3952 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
|
3953 default: SOURCING_LNUM = iptr->isn_lnum; |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
3954 emsg(_(e_modulus)); |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
3955 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
|
3956 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3957 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3958 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3959 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
|
3960 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
|
3961 --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
|
3962 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3963 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3964 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3965 { |
23681
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
3966 int failed = FALSE; |
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
3967 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3968 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
|
3969 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3970 case EXPR_MULT: n1 = n1 * n2; break; |
23681
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
3971 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
|
3972 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
|
3973 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
|
3974 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3975 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
|
3976 case EXPR_ADD: n1 = n1 + n2; break; |
23681
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
3977 default: n1 = num_modulus(n1, n2, &failed); |
423af0f7beae
patch 8.2.2382: build failure
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
3978 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
|
3979 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
|
3980 break; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3981 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3982 clear_tv(tv1); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3983 clear_tv(tv2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3984 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
|
3985 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
|
3986 --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
|
3987 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3988 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3989 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3990 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3991 case ISN_CONCAT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3992 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3993 char_u *str1 = STACK_TV_BOT(-2)->vval.v_string; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3994 char_u *str2 = STACK_TV_BOT(-1)->vval.v_string; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3995 char_u *res; |
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 res = concat_str(str1, str2); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3998 clear_tv(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
|
3999 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
|
4000 --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
|
4001 STACK_TV_BOT(-1)->vval.v_string = res; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4002 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4003 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4004 |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4005 case ISN_STRINDEX: |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4006 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
|
4007 { |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4008 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
|
4009 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
|
4010 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
|
4011 |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4012 // 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
|
4013 // 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
|
4014 // 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
|
4015 if (is_slice) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4016 { |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4017 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
|
4018 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
|
4019 } |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4020 |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4021 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
|
4022 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
|
4023 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4024 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
|
4025 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
|
4026 if (is_slice) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4027 // 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
|
4028 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
|
4029 else |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4030 // 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
|
4031 // 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
|
4032 // 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
|
4033 // empty. |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
4034 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
|
4035 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
|
4036 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
|
4037 } |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4038 break; |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4039 |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
4040 case ISN_LISTINDEX: |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4041 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
|
4042 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
|
4043 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
|
4044 { |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4045 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
|
4046 || 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
|
4047 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
|
4048 || 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
|
4049 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
|
4050 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
|
4051 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4052 // 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
|
4053 // 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
|
4054 // 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
|
4055 // 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
|
4056 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
|
4057 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4058 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
|
4059 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
|
4060 clear_tv(tv); |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4061 |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4062 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
|
4063 { |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4064 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
|
4065 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
|
4066 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
|
4067 } |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4068 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4069 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
|
4070 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
|
4071 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
|
4072 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
|
4073 { |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4074 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
|
4075 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
|
4076 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
|
4077 } |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4078 else |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4079 { |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24416
diff
changeset
|
4080 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
|
4081 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
|
4082 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
|
4083 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4084 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4085 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4086 |
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
|
4087 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
|
4088 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
|
4089 { |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4090 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
|
4091 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
|
4092 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
|
4093 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4094 // 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
|
4095 // 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
|
4096 // 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
|
4097 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
|
4098 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
|
4099 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
|
4100 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
|
4101 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
|
4102 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
|
4103 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
|
4104 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
|
4105 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
|
4106 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
|
4107 clear_tv(var2); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4108 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
|
4109 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
|
4110 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
|
4111 } |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
4112 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
|
4113 |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4114 case ISN_SLICE: |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4115 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4116 list_T *list; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4117 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
|
4118 |
20915
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
4119 // 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
|
4120 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
|
4121 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
|
4122 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4123 // 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
|
4124 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
|
4125 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4126 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
|
4127 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
|
4128 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4129 if (newlist != NULL) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4130 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4131 list_unref(list); |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4132 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
|
4133 ++newlist->lv_refcount; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4134 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4135 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4136 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4137 break; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4138 |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4139 case ISN_GETITEM: |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4140 { |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4141 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
|
4142 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
|
4143 |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
4144 // 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
|
4145 // 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
|
4146 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
|
4147 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
|
4148 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4149 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
|
4150 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4151 ++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
|
4152 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
|
4153 |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23839
diff
changeset
|
4154 // 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
|
4155 // 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
|
4156 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
|
4157 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
|
4158 } |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4159 break; |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
4160 |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4161 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
|
4162 { |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4163 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
|
4164 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
|
4165 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
|
4166 |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4167 // 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
|
4168 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
|
4169 // 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
|
4170 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
|
4171 |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4172 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
|
4173 // 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
|
4174 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
|
4175 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
|
4176 key = (char_u *)""; |
20411
23af9e1a5283
patch 8.2.0760: Vim9: dict member errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
20409
diff
changeset
|
4177 |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4178 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
|
4179 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4180 SOURCING_LNUM = iptr->isn_lnum; |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4181 semsg(_(e_dictkey), 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
|
4182 |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
4183 // 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
|
4184 // 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
|
4185 // 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
|
4186 clear_tv(tv); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4187 --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
|
4188 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
|
4189 (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
|
4190 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
|
4191 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
|
4192 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
|
4193 } |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
4194 clear_tv(tv); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4195 --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
|
4196 // 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
|
4197 // 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
|
4198 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
|
4199 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
|
4200 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
|
4201 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
|
4202 } |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4203 break; |
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20341
diff
changeset
|
4204 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4205 // 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
|
4206 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
|
4207 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4208 dict_T *dict; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4209 dictitem_T *di; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4210 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4211 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
|
4212 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
|
4213 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4214 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
|
4215 emsg(_(e_dictreq)); |
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
|
4216 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
|
4217 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4218 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
|
4219 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4220 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
|
4221 == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4222 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4223 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
|
4224 semsg(_(e_dictkey), 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
|
4225 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
|
4226 } |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4227 // 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
|
4228 // 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
|
4229 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
|
4230 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
|
4231 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4232 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
|
4233 } |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4234 break; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4235 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4236 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
|
4237 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
|
4238 break; |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4239 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4240 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
|
4241 { |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4242 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
|
4243 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4244 // 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
|
4245 // "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
|
4246 // 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
|
4247 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
|
4248 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
|
4249 && 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
|
4250 && 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
|
4251 && (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
|
4252 || (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
|
4253 && (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
|
4254 || 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
|
4255 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
|
4256 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
|
4257 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
|
4258 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4259 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4260 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4261 case ISN_NEGATENR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4262 tv = STACK_TV_BOT(-1); |
19842
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4263 if (tv->v_type != VAR_NUMBER |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4264 #ifdef FEAT_FLOAT |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4265 && tv->v_type != VAR_FLOAT |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4266 #endif |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4267 ) |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4268 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4269 SOURCING_LNUM = iptr->isn_lnum; |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
4270 emsg(_(e_number_expected)); |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4271 goto on_error; |
19842
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4272 } |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4273 #ifdef FEAT_FLOAT |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4274 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
|
4275 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
|
4276 else |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4277 #endif |
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19766
diff
changeset
|
4278 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
|
4279 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4280 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4281 case ISN_CHECKNR: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4282 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4283 int error = FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4284 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4285 tv = STACK_TV_BOT(-1); |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
4286 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
|
4287 if (check_not_string(tv) == FAIL) |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4288 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
|
4289 (void)tv_get_number_chk(tv, &error); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4290 if (error) |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4291 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
|
4292 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4293 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4294 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4295 case ISN_CHECKTYPE: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4296 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4297 checktype_T *ct = &iptr->isn_arg.type; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4298 |
23697
19073a768852
patch 8.2.2390: Vim9: using positive offset is unexpected
Bram Moolenaar <Bram@vim.org>
parents:
23695
diff
changeset
|
4299 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
|
4300 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
|
4301 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
|
4302 ectx->ec_where.wt_index = ct->ct_arg_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4303 if (check_typval_type(ct->ct_type, tv, ectx->ec_where) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4304 == 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
|
4305 goto on_error; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4306 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
|
4307 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
|
4308 |
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
|
4309 // 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
|
4310 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
|
4311 && 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
|
4312 && (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
|
4313 || 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
|
4314 { |
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
|
4315 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
|
4316 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
|
4317 ? 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
|
4318 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4319 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4320 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4321 |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4322 case ISN_CHECKLEN: |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4323 { |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4324 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
|
4325 list_T *list = NULL; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4326 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4327 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
|
4328 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
|
4329 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
|
4330 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
|
4331 || (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
|
4332 && !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
|
4333 { |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
4334 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
|
4335 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
|
4336 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
|
4337 goto on_error; |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4338 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4339 } |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4340 break; |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
4341 |
23458
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4342 case ISN_SETTYPE: |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4343 { |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4344 checktype_T *ct = &iptr->isn_arg.type; |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4345 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4346 tv = STACK_TV_BOT(-1); |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4347 if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4348 { |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4349 free_type(tv->vval.v_dict->dv_type); |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4350 tv->vval.v_dict->dv_type = alloc_type(ct->ct_type); |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4351 } |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4352 else if (tv->v_type == VAR_LIST && tv->vval.v_list != NULL) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4353 { |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4354 free_type(tv->vval.v_list->lv_type); |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4355 tv->vval.v_list->lv_type = alloc_type(ct->ct_type); |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4356 } |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4357 } |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4358 break; |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23454
diff
changeset
|
4359 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4360 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
|
4361 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
|
4362 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4363 int n; |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4364 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
|
4365 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4366 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
|
4367 { |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
4368 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
|
4369 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
|
4370 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
|
4371 n = !n; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4372 } |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4373 else |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4374 { |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
4375 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
|
4376 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
|
4377 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
|
4378 if (error) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4379 goto on_error; |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22460
diff
changeset
|
4380 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4381 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4382 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
|
4383 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
|
4384 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4385 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4386 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4387 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
|
4388 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
|
4389 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
|
4390 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
|
4391 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
|
4392 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
|
4393 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
|
4394 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4395 |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4396 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
|
4397 { |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4398 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
|
4399 char *errormsg; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4400 |
23541
a2a38bc68dd9
patch 8.2.2313: Vim9: using uninitialized field when parsing range
Bram Moolenaar <Bram@vim.org>
parents:
23527
diff
changeset
|
4401 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
|
4402 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
|
4403 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
|
4404 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
|
4405 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
|
4406 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
|
4407 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
|
4408 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
4409 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
|
4410 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4411 ++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
|
4412 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
|
4413 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
|
4414 tv->v_lock = 0; |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4415 if (ea.addr_count == 0) |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4416 tv->vval.v_number = curwin->w_cursor.lnum; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4417 else |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4418 tv->vval.v_number = ea.line2; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4419 } |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4420 break; |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4421 |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
4422 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
|
4423 { |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
4424 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
|
4425 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
|
4426 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
|
4427 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
|
4428 |
23156
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4429 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
|
4430 { |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4431 // 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
|
4432 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
|
4433 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
|
4434 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
|
4435 dir = BACKWARD; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4436 --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
|
4437 } |
6aa8ddf7a3fa
patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
4438 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
|
4439 // :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
|
4440 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
|
4441 else if (lnum >= 0) |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
4442 curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum; |
23671
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
4443 |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
4444 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
|
4445 { |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
4446 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
|
4447 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
|
4448 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
|
4449 else |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
4450 { |
9ee9c4246a7f
patch 8.2.2377: Vim9: crash when using a range after another expression
Bram Moolenaar <Bram@vim.org>
parents:
23656
diff
changeset
|
4451 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
|
4452 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
|
4453 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4454 --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
|
4455 } |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
4456 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
|
4457 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
|
4458 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
|
4459 } |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
4460 break; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
4461 |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
4462 case ISN_CMDMOD: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4463 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
|
4464 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
|
4465 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
|
4466 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
|
4467 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
|
4468 apply_cmdmod(&cmdmod); |
22691
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
4469 break; |
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
4470 |
22703
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
4471 case ISN_CMDMOD_REV: |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
4472 // 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
|
4473 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
|
4474 undo_cmdmod(&cmdmod); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4475 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
|
4476 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
|
4477 break; |
dda110a14be4
patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents:
22641
diff
changeset
|
4478 |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4479 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
|
4480 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4481 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
|
4482 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
|
4483 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
|
4484 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
|
4485 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
|
4486 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4487 // 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
|
4488 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
|
4489 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
|
4490 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4491 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
|
4492 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
|
4493 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
|
4494 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4495 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
|
4496 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
|
4497 || 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
|
4498 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4499 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
|
4500 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
|
4501 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
|
4502 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4503 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
|
4504 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4505 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
|
4506 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
|
4507 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
|
4508 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4509 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4510 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
|
4511 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
|
4512 goto theend; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4513 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
|
4514 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4515 // 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
|
4516 // items. |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4517 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
|
4518 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4519 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
|
4520 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
|
4521 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4522 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
|
4523 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
|
4524 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
|
4525 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
|
4526 ++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
|
4527 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
|
4528 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
|
4529 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
|
4530 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
|
4531 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
|
4532 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4533 list_set_item(rem_list, i, &li->li_tv); |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4534 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
|
4535 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4536 --count; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4537 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4538 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4539 // 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
|
4540 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
|
4541 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
|
4542 { |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4543 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
|
4544 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
|
4545 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
|
4546 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4547 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4548 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
|
4549 } |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4550 break; |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4551 |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4552 case ISN_PROF_START: |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4553 case ISN_PROF_END: |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4554 { |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
4555 #ifdef FEAT_PROFILE |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4556 funccall_T cookie; |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4557 ufunc_T *cur_ufunc = |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4558 (((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
|
4559 + 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
|
4560 |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4561 cookie.func = cur_ufunc; |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4562 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
|
4563 { |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4564 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
|
4565 // 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
|
4566 func_line_exec(&cookie); |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4567 } |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4568 else |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4569 func_line_end(&cookie); |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
4570 #endif |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4571 } |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4572 break; |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
4573 |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
4574 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
|
4575 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
|
4576 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
4577 |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4578 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
|
4579 { |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
4580 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
|
4581 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
|
4582 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
|
4583 |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4584 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
|
4585 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
|
4586 { |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4587 *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
|
4588 --item; |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4589 } |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4590 *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
|
4591 } |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4592 break; |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
4593 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4594 case ISN_DROP: |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4595 --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
|
4596 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
|
4597 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
|
4598 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
|
4599 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4600 } |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4601 continue; |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4602 |
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
|
4603 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
|
4604 // 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
|
4605 // 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
|
4606 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
|
4607 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
|
4608 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4609 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
|
4610 // 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
|
4611 goto theend; |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21401
diff
changeset
|
4612 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
|
4613 |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
4614 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
|
4615 // 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
|
4616 // 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
|
4617 // 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
|
4618 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
|
4619 && 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
|
4620 { |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
4621 // 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
|
4622 // 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
|
4623 // the cmdmod. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4624 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
|
4625 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4626 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
|
4627 > 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
|
4628 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4629 --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
|
4630 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
|
4631 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4632 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
|
4633 ++ectx->ec_iidx; |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
4634 } |
22760
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22758
diff
changeset
|
4635 continue; |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23681
diff
changeset
|
4636 } |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
4637 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
|
4638 // 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
|
4639 // 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
|
4640 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
|
4641 goto theend; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4642 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4643 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4644 done: |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4645 ret = OK; |
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24645
diff
changeset
|
4646 theend: |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
4647 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
|
4648 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
|
4649 return ret; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4650 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4651 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4652 /* |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4653 * Execute the instructions from a VAR_INSTR typeval and put the result in |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4654 * "rettv". |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4655 * 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
|
4656 */ |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4657 int |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4658 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
|
4659 { |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4660 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
|
4661 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
|
4662 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
|
4663 int res; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4664 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4665 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
|
4666 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
|
4667 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
|
4668 { |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4669 *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
|
4670 --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
|
4671 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4672 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4673 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
|
4674 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
|
4675 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4676 return res; |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4677 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4678 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4679 /* |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4680 * 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
|
4681 * "substitute_instr". |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4682 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4683 char_u * |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4684 exe_substitute_instr(void) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4685 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4686 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
|
4687 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
|
4688 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
|
4689 char_u *res; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4690 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4691 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
|
4692 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
|
4693 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4694 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
|
4695 |
24816
1bed37e82c2e
patch 8.2.2946: Vim9: substitute expression cannot be a List
Bram Moolenaar <Bram@vim.org>
parents:
24812
diff
changeset
|
4696 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
|
4697 --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
|
4698 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
|
4699 } |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
4700 else |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
4701 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4702 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
|
4703 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
|
4704 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4705 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4706 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
|
4707 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
|
4708 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4709 return res; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4710 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4711 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4712 /* |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4713 * 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
|
4714 * Return OK or FAIL. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4715 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4716 int |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4717 call_def_function( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4718 ufunc_T *ufunc, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4719 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
|
4720 typval_T *argv, // arguments |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4721 partial_T *partial, // optional partial for context |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4722 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
|
4723 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4724 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
|
4725 int argc = argc_arg; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4726 typval_T *tv; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4727 int idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4728 int ret = FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4729 int defcount = ufunc->uf_args.ga_len - argc; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4730 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
|
4731 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
|
4732 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
|
4733 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
|
4734 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
|
4735 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
|
4736 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
|
4737 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
|
4738 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
|
4739 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4740 // 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
|
4741 #undef STACK_TV |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4742 #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
|
4743 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4744 // 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
|
4745 #undef STACK_TV_BOT |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4746 #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
|
4747 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4748 // 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
|
4749 #undef STACK_TV_VAR |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4750 #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
|
4751 |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
4752 // Update uf_has_breakpoint if needed. |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
4753 update_has_breakpoint(ufunc); |
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24960
diff
changeset
|
4754 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4755 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
|
4756 || ufunc->uf_def_status == UF_COMPILE_ERROR |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
4757 || (func_needs_compiling(ufunc, COMPILE_TYPE(ufunc)) |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
4758 && compile_def_function(ufunc, FALSE, COMPILE_TYPE(ufunc), NULL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4759 == FAIL)) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4760 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4761 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
|
4762 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
|
4763 printable_func_name(ufunc)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4764 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4765 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4766 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4767 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4768 // 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
|
4769 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
|
4770 + ufunc->uf_dfunc_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4771 if (INSTRUCTIONS(dfunc) == NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4772 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4773 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
|
4774 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4775 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4776 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4777 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4778 // 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
|
4779 orig_funcdepth = funcdepth_get(); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4780 if (funcdepth_increment() == FAIL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4781 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4782 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4783 CLEAR_FIELD(ectx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4784 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
|
4785 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
|
4786 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
|
4787 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4788 funcdepth_decrement(); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4789 return FAIL; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4790 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4791 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
|
4792 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
|
4793 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
|
4794 ++ex_nesting_level; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4795 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4796 idx = 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
|
4797 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
|
4798 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4799 if (idx == 1) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4800 emsg(_(e_one_argument_too_many)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4801 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4802 semsg(_(e_nr_arguments_too_many), idx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4803 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4804 } |
24810
30095f94d081
patch 8.2.2943: Vim9: check for argument count ignores default values
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
4805 idx = argc - ufunc->uf_args.ga_len + ufunc->uf_def_args.ga_len; |
30095f94d081
patch 8.2.2943: Vim9: check for argument count ignores default values
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
4806 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
|
4807 { |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
4808 if (idx == -1) |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
4809 emsg(_(e_one_argument_too_few)); |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
4810 else |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
4811 semsg(_(e_nr_arguments_too_few), -idx); |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24806
diff
changeset
|
4812 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
|
4813 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4814 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4815 // Put arguments on the stack, but no more than what the function expects. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4816 // A lambda can be called with more arguments than it uses. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4817 for (idx = 0; idx < argc |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4818 && (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
|
4819 ++idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4820 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4821 if (idx >= ufunc->uf_args.ga_len - ufunc->uf_def_args.ga_len |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4822 && argv[idx].v_type == VAR_SPECIAL |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4823 && argv[idx].vval.v_number == VVAL_NONE) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4824 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4825 // Use the default value. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4826 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
|
4827 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4828 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4829 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4830 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
|
4831 && check_typval_arg_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
|
4832 ufunc->uf_arg_types[idx], &argv[idx], |
cfbf40f749b0
patch 8.2.3200: Vim9: hard to guess where a type error is given
Bram Moolenaar <Bram@vim.org>
parents:
25324
diff
changeset
|
4833 NULL, idx + 1) == FAIL) |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4834 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4835 copy_tv(&argv[idx], STACK_TV_BOT(0)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4836 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4837 ++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
|
4838 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4839 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4840 // 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
|
4841 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
|
4842 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4843 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
|
4844 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4845 if (vararg_count < 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4846 vararg_count = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4847 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4848 argc -= vararg_count; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4849 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
|
4850 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4851 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4852 // 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
|
4853 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
|
4854 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
|
4855 && 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
|
4856 && 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
|
4857 && 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
|
4858 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4859 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
|
4860 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
|
4861 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4862 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
|
4863 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4864 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
|
4865 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
|
4866 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4867 li = li->li_next; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4868 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4869 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4870 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4871 if (defcount > 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4872 // 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
|
4873 *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
|
4874 --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
|
4875 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4876 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4877 // 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
|
4878 // 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
|
4879 if (defcount > 0) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4880 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
|
4881 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4882 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
|
4883 ++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
|
4884 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4885 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
|
4886 ++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
|
4887 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4888 // 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
|
4889 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
|
4890 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
|
4891 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4892 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4893 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
|
4894 + ufunc->uf_dfunc_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4895 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
|
4896 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4897 // "uf_partial" is on the ufunc that "df_ufunc" points to, as is done |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4898 // by copy_func(). |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4899 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
|
4900 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4901 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
|
4902 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
|
4903 goto failed_early; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4904 if (partial != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4905 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4906 if (partial->pt_outer.out_stack == NULL && current_ectx != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4907 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4908 if (current_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
|
4909 && current_ectx->ec_outer_ref->or_outer != NULL) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4910 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
|
4911 current_ectx->ec_outer_ref->or_outer; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4912 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4913 else |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4914 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4915 ectx.ec_outer_ref->or_outer = &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
|
4916 ++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
|
4917 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
|
4918 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4919 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4920 else |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4921 { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
4922 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
|
4923 ++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
|
4924 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
|
4925 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4926 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4927 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4928 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4929 // dummy frame entries |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4930 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
|
4931 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4932 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
|
4933 ++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
|
4934 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4935 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4936 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4937 // 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
|
4938 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
|
4939 + ufunc->uf_dfunc_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4940 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4941 for (idx = 0; idx < dfunc->df_varcount; ++idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4942 STACK_TV_VAR(idx)->v_type = VAR_UNKNOWN; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4943 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
|
4944 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
|
4945 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4946 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
|
4947 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
|
4948 ++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
|
4949 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4950 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4951 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
|
4952 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4953 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4954 // 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
|
4955 // Commands behave like vim9script. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4956 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
|
4957 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
|
4958 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
|
4959 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4960 // 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
|
4961 // exception. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4962 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
|
4963 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
|
4964 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4965 // 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
|
4966 suppress_errthrow = FALSE; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4967 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4968 // 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
|
4969 ++ufunc->uf_calls; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4970 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4971 // 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
|
4972 // 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
|
4973 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
|
4974 did_emsg_def = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4975 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4976 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
|
4977 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
|
4978 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4979 // Execute the instructions until done. |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4980 ret = exec_instructions(&ectx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4981 if (ret == OK) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4982 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4983 // 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
|
4984 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
|
4985 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4986 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
|
4987 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4988 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4989 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4990 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
|
4991 *rettv = *tv; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4992 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
|
4993 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4994 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4995 |
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
|
4996 // When failed need to unwind the call stack. |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4997 while (ectx.ec_frame_idx != ectx.ec_initial_frame_idx) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
4998 func_return(&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
|
4999 |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5000 // 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
|
5001 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
|
5002 { |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5003 handle_closure_in_use(&ectx, FALSE); |
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
|
5004 ga_clear(&ectx.ec_funcrefs); // TODO: should not be needed? |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
5005 } |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
5006 |
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
|
5007 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
|
5008 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
|
5009 |
26445
568f93dcdc62
patch 8.2.3753: Vim9: function unreferenced while called is never deleted
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
5010 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
|
5011 // 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
|
5012 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
|
5013 |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5014 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
|
5015 { |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5016 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
|
5017 |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5018 // 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
|
5019 // the saved msg_list. |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5020 while (*plist != NULL) |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5021 plist = &(*plist)->next; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5022 |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5023 *plist = *msg_list; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5024 } |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5025 msg_list = saved_msg_list; |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22614
diff
changeset
|
5026 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5027 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
|
5028 { |
f2bfee4ac356
patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents:
22691
diff
changeset
|
5029 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
|
5030 undo_cmdmod(&cmdmod); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5031 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
|
5032 } |
23102
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
5033 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
|
5034 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
|
5035 |
20021
4895e5cf1746
patch 8.2.0566: Vim9: variable can be used uninitialized
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
5036 failed_early: |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
5037 // Free all local variables, but not arguments. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5038 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5039 clear_tv(STACK_TV(idx)); |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5040 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
|
5041 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5042 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
|
5043 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
|
5044 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
|
5045 { |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24830
diff
changeset
|
5046 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
|
5047 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
|
5048 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
|
5049 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
|
5050 } |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
5051 |
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
|
5052 // 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
|
5053 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
|
5054 |
25260
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
5055 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
|
5056 && !need_rethrow) |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
5057 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
|
5058 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
|
5059 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
|
5060 return ret; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5061 } |
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 /* |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5064 * 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
|
5065 * "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
|
5066 * "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
|
5067 */ |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5068 static void |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5069 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
|
5070 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5071 int line_idx = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5072 int prev_current = 0; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5073 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
|
5074 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
|
5075 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5076 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
|
5077 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5078 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
|
5079 char *line; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5080 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5081 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
|
5082 { |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5083 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
|
5084 && 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
|
5085 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5086 if (current > prev_current) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5087 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5088 msg_puts("\n\n"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5089 prev_current = current; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5090 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5091 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
|
5092 if (line != NULL) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5093 msg(line); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5094 } |
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
|
5095 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
|
5096 { |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5097 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
|
5098 - 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
|
5099 |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5100 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
|
5101 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
|
5102 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
|
5103 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
|
5104 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
|
5105 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
|
5106 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
|
5107 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
|
5108 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
|
5109 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
|
5110 } |
e7577f79d6eb
patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents:
24490
diff
changeset
|
5111 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5112 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5113 switch (iptr->isn_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5114 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5115 case ISN_EXEC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5116 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
|
5117 break; |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24816
diff
changeset
|
5118 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
|
5119 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
|
5120 break; |
26370
a3a0885d9dd8
patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
26325
diff
changeset
|
5121 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
|
5122 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
|
5123 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
|
5124 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
|
5125 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
|
5126 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
|
5127 break; |
24490
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
5128 case ISN_REDIRSTART: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
5129 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
|
5130 break; |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
5131 case ISN_REDIREND: |
08050e45bd06
patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents:
24488
diff
changeset
|
5132 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
|
5133 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
|
5134 break; |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
5135 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
|
5136 #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
|
5137 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
|
5138 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
|
5139 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
5140 break; |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
5141 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
|
5142 #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
|
5143 { |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
5144 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
|
5145 |
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
5146 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
|
5147 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
|
5148 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
|
5149 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
|
5150 } |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24590
diff
changeset
|
5151 #endif |
24590
2818f846f099
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents:
24549
diff
changeset
|
5152 break; |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5153 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
|
5154 { |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5155 smsg("%s%4d INSTR", pfx, current); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5156 list_instructions(" ", 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
|
5157 INT_MAX, NULL); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5158 msg(" -------------"); |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5159 } |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
5160 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5161 case ISN_SUBSTITUTE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5162 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5163 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
|
5164 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5165 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
|
5166 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
|
5167 msg(" -------------"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5168 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5169 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5170 case ISN_EXECCONCAT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5171 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
|
5172 (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
|
5173 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5174 case ISN_ECHO: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5175 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5176 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
|
5177 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5178 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
|
5179 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
|
5180 echo->echo_count); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5181 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5182 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5183 case ISN_EXECUTE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5184 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
|
5185 (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
|
5186 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5187 case ISN_ECHOMSG: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5188 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
|
5189 (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
|
5190 break; |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
5191 case ISN_ECHOCONSOLE: |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25533
diff
changeset
|
5192 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
|
5193 (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
|
5194 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5195 case ISN_ECHOERR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5196 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
|
5197 (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
|
5198 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5199 case ISN_LOAD: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5200 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5201 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
|
5202 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
|
5203 (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
|
5204 + STACK_FRAME_SIZE)); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5205 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5206 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
|
5207 (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
|
5208 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5209 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5210 case ISN_LOADOUTER: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5211 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5212 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
|
5213 smsg("%s%4d LOADOUTER level %d arg[%d]", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5214 iptr->isn_arg.outer.outer_depth, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5215 iptr->isn_arg.outer.outer_idx |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5216 + STACK_FRAME_SIZE); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5217 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5218 smsg("%s%4d LOADOUTER level %d $%d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5219 iptr->isn_arg.outer.outer_depth, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5220 iptr->isn_arg.outer.outer_idx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5221 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5222 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5223 case ISN_LOADV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5224 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
|
5225 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
|
5226 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5227 case ISN_LOADSCRIPT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5228 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5229 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
|
5230 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
|
5231 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
|
5232 |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5233 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
|
5234 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
|
5235 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
|
5236 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
|
5237 else |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5238 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
|
5239 sv->sv_name, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5240 sref->sref_idx, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5241 si->sn_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5242 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5243 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5244 case ISN_LOADS: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5245 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5246 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
|
5247 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
|
5248 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5249 smsg("%s%4d LOADS s:%s from %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5250 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
|
5251 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5252 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5253 case ISN_LOADAUTO: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5254 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
|
5255 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5256 case ISN_LOADG: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5257 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
|
5258 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5259 case ISN_LOADB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5260 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
|
5261 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5262 case ISN_LOADW: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5263 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
|
5264 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5265 case ISN_LOADT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5266 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
|
5267 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5268 case ISN_LOADGDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5269 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
|
5270 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5271 case ISN_LOADBDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5272 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
|
5273 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5274 case ISN_LOADWDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5275 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
|
5276 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5277 case ISN_LOADTDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5278 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
|
5279 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5280 case ISN_LOADOPT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5281 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
|
5282 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5283 case ISN_LOADENV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5284 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
|
5285 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5286 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
|
5287 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
|
5288 (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
|
5289 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5290 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5291 case ISN_STORE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5292 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
|
5293 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
|
5294 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
|
5295 else |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5296 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
|
5297 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
|
5298 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5299 case ISN_STOREOUTER: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5300 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5301 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
|
5302 smsg("%s%4d STOREOUTEr level %d arg[%d]", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5303 iptr->isn_arg.outer.outer_depth, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5304 iptr->isn_arg.outer.outer_idx + STACK_FRAME_SIZE); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5305 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5306 smsg("%s%4d STOREOUTER level %d $%d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5307 iptr->isn_arg.outer.outer_depth, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5308 iptr->isn_arg.outer.outer_idx); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5309 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5310 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5311 case ISN_STOREV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5312 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
|
5313 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
|
5314 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5315 case ISN_STOREAUTO: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5316 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
|
5317 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5318 case ISN_STOREG: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5319 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
|
5320 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5321 case ISN_STOREB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5322 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
|
5323 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5324 case ISN_STOREW: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5325 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
|
5326 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5327 case ISN_STORET: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5328 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
|
5329 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5330 case ISN_STORES: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5331 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5332 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
|
5333 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
|
5334 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5335 smsg("%s%4d STORES %s in %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5336 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
|
5337 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5338 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5339 case ISN_STORESCRIPT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5340 { |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5341 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
|
5342 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
|
5343 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
|
5344 |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5345 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
|
5346 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
|
5347 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
|
5348 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
|
5349 else |
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5350 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
|
5351 sv->sv_name, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5352 sref->sref_idx, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5353 si->sn_name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5354 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5355 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5356 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
|
5357 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
|
5358 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
|
5359 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
|
5360 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
|
5361 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5362 case ISN_STOREENV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5363 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
|
5364 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5365 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
|
5366 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
|
5367 (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
|
5368 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5369 case ISN_STORENR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5370 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
|
5371 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
|
5372 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
|
5373 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5374 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5375 case ISN_STOREINDEX: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5376 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
|
5377 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
|
5378 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5379 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5380 case ISN_STORERANGE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5381 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
|
5382 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5383 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5384 // constants |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5385 case ISN_PUSHNR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5386 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
|
5387 (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
|
5388 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5389 case ISN_PUSHBOOL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5390 case ISN_PUSHSPEC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5391 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
|
5392 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
|
5393 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5394 case ISN_PUSHF: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5395 #ifdef FEAT_FLOAT |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5396 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
|
5397 #endif |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5398 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5399 case ISN_PUSHS: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5400 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
|
5401 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5402 case ISN_PUSHBLOB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5403 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5404 char_u *r; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5405 char_u numbuf[NUMBUFLEN]; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5406 char_u *tofree; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5407 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5408 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
|
5409 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
|
5410 vim_free(tofree); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5411 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5412 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5413 case ISN_PUSHFUNC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5414 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5415 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
|
5416 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5417 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
|
5418 name == NULL ? "[none]" : name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5419 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5420 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5421 case ISN_PUSHCHANNEL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5422 #ifdef FEAT_JOB_CHANNEL |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5423 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5424 channel_T *channel = iptr->isn_arg.channel; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5425 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5426 smsg("%s%4d PUSHCHANNEL %d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5427 channel == NULL ? 0 : channel->ch_id); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5428 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5429 #endif |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5430 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5431 case ISN_PUSHJOB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5432 #ifdef FEAT_JOB_CHANNEL |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5433 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5434 typval_T tv; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5435 char_u *name; |
24812
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24810
diff
changeset
|
5436 char_u buf[NUMBUFLEN]; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5437 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5438 tv.v_type = VAR_JOB; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5439 tv.vval.v_job = iptr->isn_arg.job; |
24812
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24810
diff
changeset
|
5440 name = job_to_string_buf(&tv, buf); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5441 smsg("%s%4d PUSHJOB \"%s\"", pfx, current, name); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5442 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5443 #endif |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5444 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5445 case ISN_PUSHEXC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5446 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
|
5447 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5448 case ISN_UNLET: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5449 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
|
5450 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
|
5451 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
|
5452 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5453 case ISN_UNLETENV: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5454 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
|
5455 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
|
5456 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
|
5457 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5458 case ISN_UNLETINDEX: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5459 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
|
5460 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5461 case ISN_UNLETRANGE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5462 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
|
5463 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
|
5464 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
|
5465 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
|
5466 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5467 case ISN_LOCKCONST: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5468 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
|
5469 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5470 case ISN_NEWLIST: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5471 smsg("%s%4d NEWLIST size %lld", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5472 (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
|
5473 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5474 case ISN_NEWDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5475 smsg("%s%4d NEWDICT size %lld", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5476 (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
|
5477 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5478 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5479 // function call |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5480 case ISN_BCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5481 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5482 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
|
5483 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5484 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
|
5485 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
|
5486 cbfunc->cbf_argcount); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5487 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5488 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5489 case ISN_DCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5490 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5491 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
|
5492 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
|
5493 + cdfunc->cdf_idx; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5494 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5495 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
|
5496 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
|
5497 cdfunc->cdf_argcount); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5498 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5499 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5500 case ISN_UCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5501 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5502 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
|
5503 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5504 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
|
5505 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
|
5506 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5507 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5508 case ISN_PCALL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5509 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5510 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
|
5511 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5512 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
|
5513 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
|
5514 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5515 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5516 case ISN_PCALL_END: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5517 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
|
5518 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5519 case ISN_RETURN: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5520 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
|
5521 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
|
5522 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
|
5523 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
|
5524 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5525 case ISN_FUNCREF: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5526 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5527 funcref_T *funcref = &iptr->isn_arg.funcref; |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5528 char_u *name; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5529 |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5530 if (funcref->fr_func_name == NULL) |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5531 { |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5532 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
|
5533 + 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
|
5534 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
|
5535 } |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5536 else |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5537 name = funcref->fr_func_name; |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26252
diff
changeset
|
5538 smsg("%s%4d FUNCREF %s", pfx, current, name); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5539 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5540 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5541 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5542 case ISN_NEWFUNC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5543 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5544 newfunc_T *newfunc = &iptr->isn_arg.newfunc; |
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 smsg("%s%4d NEWFUNC %s %s", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5547 newfunc->nf_lambda, newfunc->nf_global); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5548 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5549 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5550 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5551 case ISN_DEF: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5552 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5553 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
|
5554 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5555 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
|
5556 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
|
5557 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5558 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5559 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5560 case ISN_JUMP: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5561 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5562 char *when = "?"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5563 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5564 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
|
5565 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5566 case JUMP_ALWAYS: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5567 when = "JUMP"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5568 break; |
25814
dd4e86558836
patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
5569 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
|
5570 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
|
5571 break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5572 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
|
5573 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
|
5574 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5575 case JUMP_IF_FALSE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5576 when = "JUMP_IF_FALSE"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5577 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5578 case JUMP_AND_KEEP_IF_FALSE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5579 when = "JUMP_AND_KEEP_IF_FALSE"; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5580 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5581 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
|
5582 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
|
5583 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5584 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
|
5585 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
|
5586 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5587 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5588 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
|
5589 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
|
5590 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5591 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5592 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5593 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
|
5594 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
|
5595 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
|
5596 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
|
5597 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5598 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5599 case ISN_FOR: |
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 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
|
5602 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5603 smsg("%s%4d FOR $%d -> %d", pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5604 forloop->for_idx, forloop->for_end); |
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 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5607 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5608 case ISN_TRY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5609 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5610 try_T *try = &iptr->isn_arg.try; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5611 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5612 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
|
5613 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
|
5614 pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5615 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
|
5616 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
|
5617 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5618 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
|
5619 pfx, current, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5620 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
|
5621 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
|
5622 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
|
5623 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5624 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5625 case ISN_CATCH: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5626 // TODO |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5627 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
|
5628 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5629 case ISN_TRYCONT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5630 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5631 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
|
5632 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5633 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
|
5634 trycont->tct_levels, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5635 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
|
5636 trycont->tct_where); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5637 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5638 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5639 case ISN_FINALLY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5640 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
|
5641 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5642 case ISN_ENDTRY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5643 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
|
5644 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5645 case ISN_THROW: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5646 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
|
5647 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5648 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5649 // expression operations on number |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5650 case ISN_OPNR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5651 case ISN_OPFLOAT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5652 case ISN_OPANY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5653 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5654 char *what; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5655 char *ins; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5656 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5657 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
|
5658 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5659 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
|
5660 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
|
5661 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
|
5662 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
|
5663 case EXPR_ADD: what = "+"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5664 default: what = "???"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5665 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5666 switch (iptr->isn_type) |
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 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
|
5669 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
|
5670 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
|
5671 default: ins = "???"; break; |
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 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
|
5674 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5675 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5676 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5677 case ISN_COMPAREBOOL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5678 case ISN_COMPARESPECIAL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5679 case ISN_COMPARENR: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5680 case ISN_COMPAREFLOAT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5681 case ISN_COMPARESTRING: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5682 case ISN_COMPAREBLOB: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5683 case ISN_COMPARELIST: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5684 case ISN_COMPAREDICT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5685 case ISN_COMPAREFUNC: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5686 case ISN_COMPAREANY: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5687 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5688 char *p; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5689 char buf[10]; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5690 char *type; |
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 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
|
5693 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5694 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
|
5695 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
|
5696 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
|
5697 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
|
5698 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
|
5699 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
|
5700 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
|
5701 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
|
5702 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
|
5703 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
|
5704 default: p = "???"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5705 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5706 STRCPY(buf, p); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5707 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
|
5708 strcat(buf, "?"); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5709 switch(iptr->isn_type) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5710 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5711 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
|
5712 case ISN_COMPARESPECIAL: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5713 type = "COMPARESPECIAL"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5714 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
|
5715 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
|
5716 case ISN_COMPARESTRING: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5717 type = "COMPARESTRING"; break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5718 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
|
5719 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
|
5720 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
|
5721 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
|
5722 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
|
5723 default: type = "???"; break; |
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 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5726 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
|
5727 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5728 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5729 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5730 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
|
5731 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
|
5732 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5733 // expression operations |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5734 case ISN_CONCAT: smsg("%s%4d CONCAT", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5735 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
|
5736 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
|
5737 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
|
5738 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
|
5739 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
|
5740 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
|
5741 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
|
5742 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
|
5743 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
|
5744 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
|
5745 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
|
5746 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
|
5747 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
|
5748 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
|
5749 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
|
5750 " with op" : ""); break; |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5751 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
|
5752 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
|
5753 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
|
5754 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
|
5755 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
|
5756 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5757 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
|
5758 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5759 case ISN_CHECKNR: smsg("%s%4d CHECKNR", pfx, current); break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5760 case ISN_CHECKTYPE: |
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 checktype_T *ct = &iptr->isn_arg.type; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5763 char *tofree; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5764 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5765 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
|
5766 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
|
5767 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
|
5768 (int)ct->ct_off); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5769 else |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
5770 smsg("%s%4d CHECKTYPE %s stack[%d] arg %d", |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
5771 pfx, current, |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5772 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
|
5773 (int)ct->ct_off, |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5774 (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
|
5775 vim_free(tofree); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5776 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5777 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5778 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
|
5779 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
|
5780 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
|
5781 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5782 case ISN_SETTYPE: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5783 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5784 char *tofree; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5785 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5786 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
|
5787 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
|
5788 vim_free(tofree); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5789 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5790 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5791 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
|
5792 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
|
5793 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
|
5794 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
|
5795 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
|
5796 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
|
5797 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
|
5798 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5799 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
|
5800 (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
|
5801 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
|
5802 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
|
5803 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
|
5804 (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
|
5805 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
|
5806 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
|
5807 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
|
5808 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5809 case ISN_PUT: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5810 if (iptr->isn_arg.put.put_lnum == LNUM_VARIABLE_RANGE_ABOVE) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5811 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
|
5812 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
|
5813 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
|
5814 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
|
5815 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
|
5816 else |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5817 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
|
5818 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
|
5819 (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
|
5820 break; |
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 // TODO: summarize modifiers |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5823 case ISN_CMDMOD: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5824 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5825 char_u *buf; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5826 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
|
5827 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
|
5828 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5829 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
|
5830 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
|
5831 { |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5832 (void)produce_cmdmods( |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5833 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
|
5834 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
|
5835 vim_free(buf); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5836 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5837 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5838 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5839 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
|
5840 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5841 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
|
5842 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
|
5843 iptr->isn_lnum); |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5844 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5845 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5846 case ISN_PROF_END: |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5847 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
|
5848 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5849 |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5850 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
|
5851 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
|
5852 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
|
5853 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
|
5854 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
|
5855 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5856 |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5857 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
|
5858 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
|
5859 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
|
5860 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5861 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
|
5862 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
|
5863 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
|
5864 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5865 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
|
5866 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5867 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
|
5868 return; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5869 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5870 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5871 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
|
5872 ui_breakcheck(); |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5873 if (got_int) |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5874 break; |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5875 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5876 } |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5877 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5878 /* |
24909
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5879 * 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
|
5880 */ |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5881 void |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5882 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
|
5883 { |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5884 char_u *p; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5885 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5886 // 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
|
5887 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
|
5888 xp->xp_pattern = arg; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5889 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5890 // 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
|
5891 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
|
5892 { |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5893 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
|
5894 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
|
5895 } |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5896 } |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5897 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5898 /* |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5899 * 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
|
5900 * arguments. |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5901 */ |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5902 char_u * |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5903 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
|
5904 { |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5905 if (idx == 0) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5906 return (char_u *)"debug"; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5907 if (idx == 1) |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5908 return (char_u *)"profile"; |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5909 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
|
5910 } |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5911 |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24899
diff
changeset
|
5912 /* |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
5913 * ":disassemble". |
19334
61646c189622
patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19328
diff
changeset
|
5914 * 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
|
5915 * 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
|
5916 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5917 void |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5918 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
|
5919 { |
19390
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5920 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
|
5921 char_u *fname; |
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19221
diff
changeset
|
5922 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
|
5923 dfunc_T *dfunc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5924 isn_T *instr; |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23699
diff
changeset
|
5925 int instr_count; |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20172
diff
changeset
|
5926 int is_global = FALSE; |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5927 compiletype_T compile_type = CT_NONE; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5928 |
26430
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26406
diff
changeset
|
5929 if (STRNCMP(arg, "profile", 7) == 0 && VIM_ISWHITE(arg[7])) |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5930 { |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5931 compile_type = CT_PROFILE; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5932 arg = skipwhite(arg + 7); |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5933 } |
26430
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26406
diff
changeset
|
5934 else if (STRNCMP(arg, "debug", 5) == 0 && VIM_ISWHITE(arg[5])) |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5935 { |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5936 compile_type = CT_DEBUG; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5937 arg = skipwhite(arg + 5); |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5938 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5939 |
21299
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5940 if (STRNCMP(arg, "<lambda>", 8) == 0) |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5941 { |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5942 arg += 8; |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5943 (void)getdigits(&arg); |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5944 fname = vim_strnsave(eap->arg, arg - eap->arg); |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5945 } |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5946 else |
883315e762b7
patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
5947 fname = trans_function_name(&arg, &is_global, FALSE, |
23527
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23523
diff
changeset
|
5948 TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD, NULL, NULL, NULL); |
19390
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5949 if (fname == NULL) |
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5950 { |
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5951 semsg(_(e_invarg2), eap->arg); |
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5952 return; |
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5953 } |
e4b326c9424a
patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents:
19342
diff
changeset
|
5954 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20172
diff
changeset
|
5955 ufunc = find_func(fname, is_global, NULL); |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5956 if (ufunc == NULL) |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5957 { |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5958 char_u *p = untrans_function_name(fname); |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5959 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5960 if (p != NULL) |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5961 // Try again without making it script-local. |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20172
diff
changeset
|
5962 ufunc = find_func(p, FALSE, NULL); |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20021
diff
changeset
|
5963 } |
19281
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19221
diff
changeset
|
5964 vim_free(fname); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5965 if (ufunc == NULL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5966 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
5967 semsg(_(e_cannot_find_function_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
|
5968 return; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5969 } |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5970 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
|
5971 && 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
|
5972 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
|
5973 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
|
5974 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21815
diff
changeset
|
5975 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
|
5976 return; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5977 } |
25461
891d08245543
patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
5978 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
|
5979 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5980 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
|
5981 switch (compile_type) |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5982 { |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5983 case CT_PROFILE: |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
5984 #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
|
5985 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
|
5986 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
|
5987 break; |
23719
1a7c2685d780
patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
5988 #endif |
24895
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5989 // FALLTHROUGH |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5990 case CT_NONE: |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5991 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
|
5992 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
|
5993 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5994 case CT_DEBUG: |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5995 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
|
5996 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
|
5997 break; |
e61a2085c89b
patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
5998 } |
24488
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
5999 |
f293bb501b30
patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
6000 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
|
6001 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6002 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6003 /* |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
6004 * 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
|
6005 * 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
|
6006 * 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
|
6007 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6008 int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6009 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
|
6010 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6011 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
|
6012 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6013 case VAR_NUMBER: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6014 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
|
6015 case VAR_FLOAT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6016 #ifdef FEAT_FLOAT |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6017 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
|
6018 #else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6019 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6020 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6021 case VAR_PARTIAL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6022 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
|
6023 case VAR_FUNC: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6024 case VAR_STRING: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6025 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
|
6026 case VAR_LIST: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6027 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
|
6028 case VAR_DICT: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6029 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
|
6030 && 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
|
6031 case VAR_BOOL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6032 case VAR_SPECIAL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6033 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
|
6034 case VAR_JOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6035 #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
|
6036 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
|
6037 #else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6038 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6039 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6040 case VAR_CHANNEL: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6041 #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
|
6042 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
|
6043 #else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6044 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6045 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6046 case VAR_BLOB: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6047 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
|
6048 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
|
6049 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
|
6050 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
|
6051 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
|
6052 break; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6053 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6054 return FALSE; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6055 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6056 |
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
|
6057 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
|
6058 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
|
6059 { |
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
|
6060 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
|
6061 : 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
|
6062 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
|
6063 ? (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
|
6064 } |
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
|
6065 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6066 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6067 * 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
|
6068 */ |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6069 int |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6070 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
|
6071 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6072 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
|
6073 { |
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
|
6074 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
|
6075 clear_tv(tv); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6076 return FAIL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6077 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6078 return OK; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6079 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6080 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6081 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6082 #endif // FEAT_EVAL |