Mercurial > vim
annotate src/vim9expr.c @ 32039:f08ee1b65dbf v9.0.1351
patch 9.0.1351: Dhall files are not recognized
Commit: https://github.com/vim/vim/commit/def5521752abefe12db8cc3111a3b205ad1ac929
Author: Amaan Qureshi <amaanq12@gmail.com>
Date: Fri Feb 24 16:01:54 2023 +0000
patch 9.0.1351: Dhall files are not recognized
Problem: Dhall files are not recognized.
Solution: Add patterns for Dhall files. (Amaan Qureshi, closes https://github.com/vim/vim/issues/12052)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 Feb 2023 17:15:05 +0100 |
parents | ef644af2c330 |
children | cdab211f342a |
rev | line source |
---|---|
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
29759
d19adfd545e2
patch 9.0.0219: cannot make a funcref with "s:func" in a def function
Bram Moolenaar <Bram@vim.org>
parents:
28992
diff
changeset
|
11 * vim9expr.c: Dealing with compiled function expressions |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #define USING_FLOAT_STUFF |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 #include "vim.h" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 #if defined(FEAT_EVAL) || defined(PROTO) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 // When not generating protos this is included in proto.h |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 #ifdef PROTO |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 # include "vim9.h" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 #endif |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
24 // flag passed from compile_subscript() to compile_load_scriptvar() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
25 static int paren_follows_after_expr = 0; |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
26 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 * Generate code for any ppconst entries. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 generate_ppconst(cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 int ret = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 int save_skip = cctx->ctx_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 cctx->ctx_skip = SKIP_NOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 for (i = 0; i < ppconst->pp_used; ++i) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 if (generate_tv_PUSH(cctx, &ppconst->pp_tv[i]) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 ppconst->pp_used = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 cctx->ctx_skip = save_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 * Check that the last item of "ppconst" is a bool, if there is an item. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 check_ppconst_bool(ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 if (ppconst->pp_used > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 where_T where = WHERE_INIT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 return check_typval_type(&t_bool, tv, where); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 * Clear ppconst constants. Used when failing. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 clear_ppconst(ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 for (i = 0; i < ppconst->pp_used; ++i) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 clear_tv(&ppconst->pp_tv[i]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 ppconst->pp_used = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 * Compile getting a member from a list/dict/string/blob. Stack has the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 * indexable value and the index or the two indexes of a slice. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 * "keeping_dict" is used for dict[func](arg) to pass dict to func. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 compile_member(int is_slice, int *keeping_dict, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
83 type2_T *typep; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 garray_T *stack = &cctx->ctx_type_stack; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 vartype_T vartype; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 type_T *idxtype; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 // We can index a list, dict and blob. If we don't know the type |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 // we can use the index value type. If we still don't know use an "ANY" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 // instruction. |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
91 // TODO: what about the decl type? |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
92 typep = (((type2_T *)stack->ga_data) + stack->ga_len - (is_slice ? 3 : 2)); |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
93 vartype = typep->type_curr->tt_type; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
94 idxtype = (((type2_T *)stack->ga_data) + stack->ga_len - 1)->type_curr; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 // If the index is a string, the variable must be a Dict. |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
96 if ((typep->type_curr->tt_type == VAR_ANY |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
97 || typep->type_curr->tt_type == VAR_UNKNOWN) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
98 && idxtype == &t_string) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 vartype = VAR_DICT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 if (vartype == VAR_STRING || vartype == VAR_LIST || vartype == VAR_BLOB) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 { |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
102 if (need_type(idxtype, &t_number, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
103 -1, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
107 idxtype = get_type_on_stack(cctx, 1); |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
108 if (need_type(idxtype, &t_number, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
109 -2, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 if (vartype == VAR_DICT) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 emsg(_(e_cannot_slice_dictionary)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 } |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
121 if (typep->type_curr->tt_type == VAR_DICT) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
123 typep->type_curr = typep->type_curr->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
124 if (typep->type_curr == &t_unknown) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 // empty dict was used |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
126 typep->type_curr = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
127 if (typep->type_decl->tt_type == VAR_DICT) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
128 { |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
129 typep->type_decl = typep->type_decl->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
130 if (typep->type_decl == &t_unknown) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
131 // empty dict was used |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
132 typep->type_decl = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
133 } |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
134 else |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
135 typep->type_decl = typep->type_curr; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 { |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
139 if (need_type(typep->type_curr, &t_dict_any, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
140 -2, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 return FAIL; |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
142 typep->type_curr = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
143 typep->type_decl = &t_any; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 } |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
145 if (may_generate_2STRING(-1, FALSE, cctx) == FAIL |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
146 || generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 if (keeping_dict != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 *keeping_dict = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 else if (vartype == VAR_STRING) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
153 typep->type_curr = &t_string; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
154 typep->type_decl = &t_string; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 if ((is_slice |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 ? generate_instr_drop(cctx, ISN_STRSLICE, 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 : generate_instr_drop(cctx, ISN_STRINDEX, 1)) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 else if (vartype == VAR_BLOB) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
164 typep->type_curr = &t_blob; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
165 typep->type_decl = &t_blob; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 if (generate_instr_drop(cctx, ISN_BLOBSLICE, 2) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
171 typep->type_curr = &t_number; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
172 typep->type_decl = &t_number; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 if (generate_instr_drop(cctx, ISN_BLOBINDEX, 1) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 } |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
177 else if (vartype == VAR_LIST || typep->type_curr->tt_type == VAR_ANY |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
178 || typep->type_curr->tt_type == VAR_UNKNOWN) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 if (generate_instr_drop(cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 vartype == VAR_LIST ? ISN_LISTSLICE : ISN_ANYSLICE, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 2) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 return FAIL; |
27573
68eac9355e49
patch 8.2.4313: Vim9: cannot change type of list after making a slice
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
186 // a copy is made so the member type is no longer declared |
68eac9355e49
patch 8.2.4313: Vim9: cannot change type of list after making a slice
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
187 if (typep->type_decl->tt_type == VAR_LIST) |
68eac9355e49
patch 8.2.4313: Vim9: cannot change type of list after making a slice
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
188 typep->type_decl = &t_list_any; |
31010
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
189 |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
190 // a copy is made, the composite is no longer "const" |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
191 if (typep->type_curr->tt_flags & TTFLAG_CONST) |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
192 { |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
193 type_T *type = copy_type(typep->type_curr, cctx->ctx_type_list); |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
194 |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
195 if (type != typep->type_curr) // did get a copy |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
196 { |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
197 type->tt_flags &= ~(TTFLAG_CONST | TTFLAG_STATIC); |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
198 typep->type_curr = type; |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
199 } |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
200 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
204 if (typep->type_curr->tt_type == VAR_LIST) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
206 typep->type_curr = typep->type_curr->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
207 if (typep->type_curr == &t_unknown) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 // empty list was used |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
209 typep->type_curr = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
210 if (typep->type_decl->tt_type == VAR_LIST) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
211 { |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
212 typep->type_decl = typep->type_decl->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
213 if (typep->type_decl == &t_unknown) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
214 // empty list was used |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
215 typep->type_decl = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
216 } |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
217 else |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
218 typep->type_decl = typep->type_curr; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 if (generate_instr_drop(cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 vartype == VAR_LIST ? ISN_LISTINDEX : ISN_ANYINDEX, 1) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 switch (vartype) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 case VAR_FUNC: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 case VAR_PARTIAL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 emsg(_(e_cannot_index_a_funcref)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 case VAR_BOOL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 case VAR_SPECIAL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 case VAR_JOB: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 case VAR_CHANNEL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 case VAR_INSTR: |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31010
diff
changeset
|
239 case VAR_CLASS: |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31010
diff
changeset
|
240 case VAR_OBJECT: |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 case VAR_UNKNOWN: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 case VAR_ANY: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 case VAR_VOID: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 emsg(_(e_cannot_index_special_variable)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 default: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 emsg(_(e_string_list_dict_or_blob_required)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 /* |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
255 * Compile ".member" coming after an object or class. |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
256 */ |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
257 static int |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
258 compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type) |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
259 { |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
260 if (VIM_ISWHITE((*arg)[1])) |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
261 { |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
262 semsg(_(e_no_white_space_allowed_after_str_str), ".", *arg); |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
263 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
264 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
265 |
32005
ef644af2c330
patch 9.0.1334: using tt_member for the class leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
31982
diff
changeset
|
266 class_T *cl = type->tt_class; |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
267 int is_super = type->tt_flags & TTFLAG_SUPER; |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
268 if (type == &t_super) |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
269 { |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
270 if (cctx->ctx_ufunc == NULL || cctx->ctx_ufunc->uf_class == NULL) |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
271 { |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
272 emsg(_(e_using_super_not_in_class_function)); |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
273 return FAIL; |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
274 } |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
275 is_super = TRUE; |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
276 cl = cctx->ctx_ufunc->uf_class; |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
277 // Remove &t_super from the stack. |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
278 --cctx->ctx_type_stack.ga_len; |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
279 } |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
280 else if (type->tt_type == VAR_CLASS) |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
281 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
282 garray_T *instr = &cctx->ctx_instr; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
283 if (instr->ga_len > 0) |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
284 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
285 isn_T *isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
286 if (isn->isn_type == ISN_LOADSCRIPT) |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
287 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
288 // The class was recognized as a script item. We only need |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
289 // to know what class it is, drop the instruction. |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
290 --instr->ga_len; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
291 vim_free(isn->isn_arg.script.scriptref); |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
292 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
293 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
294 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
295 |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
296 ++*arg; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
297 char_u *name = *arg; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
298 char_u *name_end = find_name_end(name, NULL, NULL, FNE_CHECK_START); |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
299 if (name_end == name) |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
300 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
301 size_t len = name_end - name; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
302 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
303 if (*name_end == '(') |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
304 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
305 int function_count; |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
306 int child_count; |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
307 ufunc_T **functions; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
308 |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
309 if (type->tt_type == VAR_CLASS) |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
310 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
311 function_count = cl->class_class_function_count; |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
312 child_count = cl->class_class_function_count_child; |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
313 functions = cl->class_class_functions; |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
314 } |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
315 else |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
316 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
317 // type->tt_type == VAR_OBJECT: method call |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
318 function_count = cl->class_obj_method_count; |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
319 child_count = cl->class_obj_method_count_child; |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
320 functions = cl->class_obj_methods; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
321 } |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
322 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
323 ufunc_T *ufunc = NULL; |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
324 int fi; |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
325 for (fi = is_super ? child_count : 0; fi < function_count; ++fi) |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
326 { |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
327 ufunc_T *fp = functions[fi]; |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
328 // Use a separate pointer to avoid that ASAN complains about |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
329 // uf_name[] only being 4 characters. |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
330 char_u *ufname = (char_u *)fp->uf_name; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
331 if (STRNCMP(name, ufname, len) == 0 && ufname[len] == NUL) |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
332 { |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
333 ufunc = fp; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
334 break; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
335 } |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
336 } |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
337 if (ufunc == NULL) |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
338 { |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
339 // TODO: different error for object method? |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
340 semsg(_(e_method_not_found_on_class_str_str), cl->class_name, name); |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
341 return FAIL; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
342 } |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
343 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
344 // Compile the arguments and call the class function or object method. |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
345 // The object method will know that the object is on the stack, just |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
346 // before the arguments. |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
347 *arg = skipwhite(name_end + 1); |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
348 int argcount = 0; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
349 if (compile_arguments(arg, cctx, &argcount, CA_NOT_SPECIAL) == FAIL) |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
350 return FAIL; |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
351 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
352 if (type->tt_type == VAR_OBJECT |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
353 && (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
354 return generate_CALL(cctx, ufunc, cl, fi, argcount); |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
355 return generate_CALL(cctx, ufunc, NULL, 0, argcount); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
356 } |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
357 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
358 if (type->tt_type == VAR_OBJECT) |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
359 { |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
360 for (int i = 0; i < cl->class_obj_member_count; ++i) |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
361 { |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
362 ocmember_T *m = &cl->class_obj_members[i]; |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
363 if (STRNCMP(name, m->ocm_name, len) == 0 && m->ocm_name[len] == NUL) |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
364 { |
31815
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
365 if (*name == '_' && !inside_class(cctx, cl)) |
31455
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31424
diff
changeset
|
366 { |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
367 semsg(_(e_cannot_access_private_member_str), m->ocm_name); |
31455
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31424
diff
changeset
|
368 return FAIL; |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31424
diff
changeset
|
369 } |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31424
diff
changeset
|
370 |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
371 *arg = name_end; |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
372 if (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED)) |
31754
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
373 return generate_GET_ITF_MEMBER(cctx, cl, i, m->ocm_type); |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
374 return generate_GET_OBJ_MEMBER(cctx, i, m->ocm_type); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
375 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
376 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
377 |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
378 // Could be a function reference: "obj.Func". |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
379 for (int i = 0; i < cl->class_obj_method_count; ++i) |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
380 { |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
381 ufunc_T *fp = cl->class_obj_methods[i]; |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
382 // Use a separate pointer to avoid that ASAN complains about |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
383 // uf_name[] only being 4 characters. |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
384 char_u *ufname = (char_u *)fp->uf_name; |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
385 if (STRNCMP(name, ufname, len) == 0 && ufname[len] == NUL) |
31920
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
386 { |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
387 if (type->tt_type == VAR_OBJECT |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
388 && (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))) |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
389 return generate_FUNCREF(cctx, fp, cl, i, NULL); |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
390 return generate_FUNCREF(cctx, fp, NULL, 0, NULL); |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
391 } |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
392 } |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
393 |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
394 semsg(_(e_member_not_found_on_object_str_str), cl->class_name, name); |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
395 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
396 else |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
397 { |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
398 // load class member |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
399 int idx; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
400 for (idx = 0; idx < cl->class_class_member_count; ++idx) |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
401 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
402 ocmember_T *m = &cl->class_class_members[idx]; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
403 if (STRNCMP(name, m->ocm_name, len) == 0 && m->ocm_name[len] == NUL) |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
404 break; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
405 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
406 if (idx < cl->class_class_member_count) |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
407 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
408 *arg = name_end; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
409 return generate_CLASSMEMBER(cctx, TRUE, cl, idx); |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
410 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
411 semsg(_(e_class_member_not_found_str), name); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
412 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
413 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
414 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
415 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
416 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
417 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 * Generate an instruction to load script-local variable "name", without the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 * leading "s:". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 * Also finds imported variables. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 compile_load_scriptvar( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 char_u *name, // variable NUL terminated |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 char_u *start, // start of variable |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
427 char_u **end) // end of variable, may be NULL |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 scriptitem_T *si; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 imported_T *import; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 if (!SCRIPT_ID_VALID(current_sctx.sc_sid)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 si = SCRIPT_ITEM(current_sctx.sc_sid); |
27613
42d0279c6e7c
patch 8.2.4333: cstack not always passed to where it is needed
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
436 idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx, NULL); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 generate_VIM9SCRIPT(cctx, ISN_LOADSCRIPT, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 current_sctx.sc_sid, idx, sv->sv_type); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
446 import = end == NULL ? NULL : find_imported(name, 0, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 if (import != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 { |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
449 char_u *p = skipwhite(*end); |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
450 char_u *exp_name; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
451 int cc; |
28271
c84f4e34ba16
patch 8.2.4661: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
452 ufunc_T *ufunc = NULL; |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
453 type_T *type; |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
454 int done = FALSE; |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
455 int res = OK; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
457 // Need to lookup the member. |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
458 if (*p != '.') |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
459 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
460 semsg(_(e_expected_dot_after_name_str), start); |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
461 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
462 } |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
463 ++p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
464 if (VIM_ISWHITE(*p)) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
465 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
466 emsg(_(e_no_white_space_allowed_after_dot)); |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
467 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
468 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
470 // isolate one name |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
471 exp_name = p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
472 while (eval_isnamec(*p)) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
473 ++p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
474 cc = *p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
475 *p = NUL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
476 |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
477 si = SCRIPT_ITEM(import->imp_sid); |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
478 if (si->sn_import_autoload && si->sn_state == SN_STATE_NOT_LOADED) |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
479 // "import autoload './dir/script.vim'" or |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
480 // "import autoload './autoload/script.vim'" - load script first |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
481 res = generate_SOURCE(cctx, import->imp_sid); |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
482 |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
483 if (res == OK) |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
484 { |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
485 if (si->sn_autoload_prefix != NULL |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
486 && si->sn_state == SN_STATE_NOT_LOADED) |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
487 { |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
488 char_u *auto_name = |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
489 concat_str(si->sn_autoload_prefix, exp_name); |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
490 |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
491 // autoload script must be loaded later, access by the autoload |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
492 // name. If a '(' follows it must be a function. Otherwise we |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
493 // don't know, it can be "script.Func". |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
494 if (cc == '(' || paren_follows_after_expr) |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
495 res = generate_PUSHFUNC(cctx, auto_name, &t_func_any, TRUE); |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
496 else |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
497 res = generate_AUTOLOAD(cctx, auto_name, &t_any); |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
498 vim_free(auto_name); |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
499 done = TRUE; |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
500 } |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
501 else if (si->sn_import_autoload |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
502 && si->sn_state == SN_STATE_NOT_LOADED) |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
503 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
504 // If a '(' follows it must be a function. Otherwise we don't |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
505 // know, it can be "script.Func". |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
506 if (cc == '(' || paren_follows_after_expr) |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
507 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
508 char_u sid_name[MAX_FUNC_NAME_LEN]; |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
509 |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
510 func_name_with_sid(exp_name, import->imp_sid, sid_name); |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
511 res = generate_PUSHFUNC(cctx, sid_name, &t_func_any, TRUE); |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
512 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
513 else |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
514 res = generate_OLDSCRIPT(cctx, ISN_LOADEXPORT, exp_name, |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
515 import->imp_sid, &t_any); |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
516 done = TRUE; |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
517 } |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
518 else |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
519 { |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
520 idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
521 cctx, NULL, TRUE); |
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
522 } |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
523 } |
28261
20f6b0cdf38c
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dir
Bram Moolenaar <Bram@vim.org>
parents:
28249
diff
changeset
|
524 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
525 *p = cc; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
526 *end = p; |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
527 if (done) |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
528 return res; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
530 if (idx < 0) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
531 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
532 if (ufunc != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 { |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
534 // function call or function reference |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
535 generate_PUSHFUNC(cctx, ufunc->uf_name, NULL, TRUE); |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
536 return OK; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 } |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
538 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
539 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
541 generate_VIM9SCRIPT(cctx, ISN_LOADSCRIPT, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
542 import->imp_sid, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
543 idx, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
544 type); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
548 // Can only get here if we know "name" is a script variable and not in a |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
549 // Vim9 script (variable is not in sn_var_vals): old style script. |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
550 return generate_OLDSCRIPT(cctx, ISN_LOADS, name, current_sctx.sc_sid, |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
551 &t_any); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 static int |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
555 generate_funcref(cctx_T *cctx, char_u *name, int has_g_prefix) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 { |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
557 ufunc_T *ufunc = find_func(name, FALSE); |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
558 compiletype_T compile_type; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
560 // Reject a global non-autoload function found without the "g:" prefix. |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
561 if (ufunc == NULL || (!has_g_prefix && func_requires_g_prefix(ufunc))) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 // Need to compile any default values to get the argument types. |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
565 compile_type = get_compile_type(ufunc); |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
566 if (func_needs_compiling(ufunc, compile_type) |
28111
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28101
diff
changeset
|
567 && compile_def_function(ufunc, TRUE, compile_type, NULL) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 return FAIL; |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
569 return generate_PUSHFUNC(cctx, ufunc->uf_name, ufunc->uf_func_type, TRUE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 * Compile a variable name into a load instruction. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 * "end" points to just after the name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 * "is_expr" is TRUE when evaluating an expression, might be a funcref. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 * When "error" is FALSE do not give an error when not found. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 compile_load( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 char_u *end_arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 int is_expr, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 int error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 type_T *type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 char_u *name = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 char_u *end = end_arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 int res = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 int prev_called_emsg = called_emsg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 if (*(*arg + 1) == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 if (end <= *arg + 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 isntype_T isn_type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 // load dictionary of namespace |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 case 'g': isn_type = ISN_LOADGDICT; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 case 'w': isn_type = ISN_LOADWDICT; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 case 't': isn_type = ISN_LOADTDICT; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 case 'b': isn_type = ISN_LOADBDICT; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 default: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 semsg(_(e_namespace_not_supported_str), *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 if (generate_instr_type(cctx, isn_type, &t_dict_any) == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 res = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 isntype_T isn_type = ISN_DROP; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 // load namespaced variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 name = vim_strnsave(*arg + 2, end - (*arg + 2)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 { |
28992
0e9642706a59
patch 8.2.5018: Vim9: some code is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
624 case 'v': res = generate_LOADV(cctx, name); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 break; |
27843
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
626 case 's': if (current_script_is_vim9()) |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
627 { |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
628 semsg(_(e_cannot_use_s_colon_in_vim9_script_str), |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
629 *arg); |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
630 vim_free(name); |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
631 return FAIL; |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
632 } |
29759
d19adfd545e2
patch 9.0.0219: cannot make a funcref with "s:func" in a def function
Bram Moolenaar <Bram@vim.org>
parents:
28992
diff
changeset
|
633 if (is_expr && find_func(name, FALSE) != NULL) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
634 res = generate_funcref(cctx, name, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 res = compile_load_scriptvar(cctx, name, |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
637 NULL, &end); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 if (is_expr && ASCII_ISUPPER(*name) |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
642 && find_func(name, FALSE) != NULL) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
643 res = generate_funcref(cctx, name, TRUE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 isn_type = ISN_LOADG; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 isn_type = ISN_LOADAUTO; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 name = vim_strnsave(*arg, end - *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 case 'w': isn_type = ISN_LOADW; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 case 't': isn_type = ISN_LOADT; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 case 'b': isn_type = ISN_LOADB; break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 default: // cannot happen, just in case |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 semsg(_(e_namespace_not_supported_str), *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 if (isn_type != ISN_DROP) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 // Global, Buffer-local, Window-local and Tabpage-local |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 // variables can be defined later, thus we don't check if it |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 // exists, give an error at runtime. |
26680
1b288eb2fcdc
patch 8.2.3869: Vim9: type checking for "any" is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26674
diff
changeset
|
668 res = generate_LOAD(cctx, isn_type, 0, name, &t_any); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 size_t len = end - *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 int gen_load = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 int gen_load_outer = 0; |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
678 int outer_loop_depth = -1; |
30291
61a688be1899
patch 9.0.0481: in :def function all closures in loop get the same variables
Bram Moolenaar <Bram@vim.org>
parents:
30209
diff
changeset
|
679 int outer_loop_idx = -1; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 name = vim_strnsave(*arg, end - *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
685 if (STRCMP(name, "super") == 0 |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
686 && cctx->ctx_ufunc != NULL |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
687 && (cctx->ctx_ufunc->uf_flags & (FC_OBJECT|FC_NEW)) == 0) |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
688 { |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
689 // super.SomeFunc() in a class function: push &t_super type, this |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
690 // is recognized in compile_subscript(). |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
691 res = push_type_stack(cctx, &t_super); |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
692 if (*end != '.') |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
693 emsg(_(e_super_must_be_followed_by_dot)); |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
694 } |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
695 else if (vim_strchr(name, AUTOLOAD_CHAR) != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 script_autoload(name, FALSE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 res = generate_LOAD(cctx, ISN_LOADAUTO, 0, name, &t_any); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 else if (arg_exists(*arg, len, &idx, &type, &gen_load_outer, cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 if (gen_load_outer == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 gen_load = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 { |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
708 lvar_T lvar; |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
709 class_T *cl = NULL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 if (lookup_local(*arg, len, &lvar, cctx) == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 type = lvar.lv_type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 idx = lvar.lv_idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 if (lvar.lv_from_outer != 0) |
30437
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
716 { |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 gen_load_outer = lvar.lv_from_outer; |
30437
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
718 outer_loop_depth = lvar.lv_loop_depth; |
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
719 outer_loop_idx = lvar.lv_loop_idx; |
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
720 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 gen_load = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 } |
31590
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
724 else if ((idx = class_member_index(*arg, len, &cl, cctx)) >= 0) |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
725 { |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
726 res = generate_CLASSMEMBER(cctx, TRUE, cl, idx); |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
727 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 // "var" can be script-local even without using "s:" if it |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 // already exists in a Vim9 script or when it's imported. |
27611
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27573
diff
changeset
|
732 if (script_var_exists(*arg, len, cctx, NULL) == OK |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
733 || find_imported(name, 0, FALSE) != NULL) |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
734 res = compile_load_scriptvar(cctx, name, *arg, &end); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 // When evaluating an expression and the name starts with an |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 // uppercase letter it can be a user defined function. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 // generate_funcref() will fail if the function can't be found. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 if (res == FAIL && is_expr && ASCII_ISUPPER(*name)) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
740 res = generate_funcref(cctx, name, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 if (gen_load) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 res = generate_LOAD(cctx, ISN_LOAD, idx, NULL, type); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 if (gen_load_outer > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 { |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
747 res = generate_LOADOUTER(cctx, idx, gen_load_outer, |
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
748 outer_loop_depth, outer_loop_idx, type); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 cctx->ctx_outer_used = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 *arg = end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 theend: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 if (res == FAIL && error && called_emsg == prev_called_emsg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 semsg(_(e_variable_not_found_str), name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 return res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 * Compile a string in a ISN_PUSHS instruction into an ISN_INSTR. |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
764 * "str_offset" is the number of leading bytes to skip from the string. |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 * Returns FAIL if compilation fails. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 static int |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
768 compile_string(isn_T *isn, cctx_T *cctx, int str_offset) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 { |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
770 char_u *s = isn->isn_arg.string + str_offset; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 garray_T save_ga = cctx->ctx_instr; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 int expr_res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 int trailing_error; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 int instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 isn_T *instr = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 // Remove the string type from the stack. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 --cctx->ctx_type_stack.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 // Temporarily reset the list of instructions so that the jump labels are |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 // correct. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 cctx->ctx_instr.ga_len = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 cctx->ctx_instr.ga_maxlen = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 cctx->ctx_instr.ga_data = NULL; |
31663
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
785 |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
786 // avoid peeking a next line |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
787 int galen_save = cctx->ctx_ufunc->uf_lines.ga_len; |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
788 cctx->ctx_ufunc->uf_lines.ga_len = 0; |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
789 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 expr_res = compile_expr0(&s, cctx); |
31663
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
791 |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
792 cctx->ctx_ufunc->uf_lines.ga_len = galen_save; |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
793 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 s = skipwhite(s); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 trailing_error = *s != NUL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 if (expr_res == FAIL || trailing_error |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 || GA_GROW_FAILS(&cctx->ctx_instr, 1)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 if (trailing_error) |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
801 semsg(_(e_trailing_characters_str), s); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 clear_instr_ga(&cctx->ctx_instr); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 cctx->ctx_instr = save_ga; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 ++cctx->ctx_type_stack.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 // Move the generated instructions into the ISN_INSTR instruction, then |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 // restore the list of instructions. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 instr_count = cctx->ctx_instr.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 instr = cctx->ctx_instr.ga_data; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 instr[instr_count].isn_type = ISN_FINISH; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 cctx->ctx_instr = save_ga; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 vim_free(isn->isn_arg.string); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 isn->isn_type = ISN_INSTR; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 isn->isn_arg.instr = instr; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 * Compile the argument expressions. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 * "arg" points to just after the "(" and is advanced to after the ")" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 */ |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
825 int |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
826 compile_arguments( |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
827 char_u **arg, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
828 cctx_T *cctx, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
829 int *argcount, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
830 ca_special_T special_fn) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 char_u *p = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 char_u *whitep = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 int must_end = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 int instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 if (may_get_next_line(whitep, &p, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 if (*p == ')') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 *arg = p + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 if (must_end) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 semsg(_(e_missing_comma_before_argument_str), p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 instr_count = cctx->ctx_instr.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 if (compile_expr0(&p, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 ++*argcount; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
857 if (special_fn == CA_SEARCHPAIR && *argcount == 5 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 && cctx->ctx_instr.ga_len == instr_count + 1) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 isn_T *isn = ((isn_T *)cctx->ctx_instr.ga_data) + instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 // {skip} argument of searchpair() can be compiled if not empty |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 if (isn->isn_type == ISN_PUSHS && *isn->isn_arg.string != NUL) |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
864 compile_string(isn, cctx, 0); |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
865 } |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
866 else if (special_fn == CA_SUBSTITUTE && *argcount == 3 |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
867 && cctx->ctx_instr.ga_len == instr_count + 1) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
868 { |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
869 isn_T *isn = ((isn_T *)cctx->ctx_instr.ga_data) + instr_count; |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
870 |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
871 // {sub} argument of substitute() can be compiled if it starts |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
872 // with \= |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
873 if (isn->isn_type == ISN_PUSHS && isn->isn_arg.string[0] == '\\' |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
874 && isn->isn_arg.string[1] == '=') |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
875 compile_string(isn, cctx, 2); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 if (*p != ',' && *skipwhite(p) == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 semsg(_(e_no_white_space_allowed_before_str_str), ",", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 if (*p != NUL && !VIM_ISWHITE(*p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 semsg(_(e_white_space_required_after_str_str), ",", p - 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 must_end = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 whitep = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 failret: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 emsg(_(e_missing_closing_paren)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 * Compile a function call: name(arg1, arg2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 * "arg" points to "name", "arg + varlen" to the "(". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 * "argcount_init" is 1 for "value->method()" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 * Instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 * EVAL arg1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 * EVAL arg2 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 * BCALL / DCALL / UCALL |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 compile_call( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 size_t varlen, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 ppconst_T *ppconst, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 int argcount_init) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 char_u *name = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 int argcount = argcount_init; |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
919 char_u namebuf[MAX_FUNC_NAME_LEN]; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 char_u fname_buf[FLEN_FIXED + 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 char_u *tofree = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 ufunc_T *ufunc = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 int res = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 int is_autoload; |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
925 int has_g_namespace; |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
926 ca_special_T special_fn; |
27235
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
927 imported_T *import; |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
928 |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
929 if (varlen >= sizeof(namebuf)) |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
930 { |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
931 semsg(_(e_name_too_long_str), name); |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
932 return FAIL; |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
933 } |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
934 vim_strncpy(namebuf, *arg, varlen); |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
935 |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
936 import = find_imported(name, varlen, FALSE); |
27235
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
937 if (import != NULL) |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
938 { |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
939 semsg(_(e_cannot_use_str_itself_it_is_imported), namebuf); |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
940 return FAIL; |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
941 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 // We can evaluate "has('name')" at compile time. |
28287
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
944 // We can evaluate "len('string')" at compile time. |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 // We always evaluate "exists_compiled()" at compile time. |
28287
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
946 if ((varlen == 3 |
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
947 && (STRNCMP(*arg, "has", 3) == 0 || STRNCMP(*arg, "len", 3) == 0)) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 || (varlen == 15 && STRNCMP(*arg, "exists_compiled", 6) == 0)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 char_u *s = skipwhite(*arg + varlen + 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 typval_T argvars[2]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 int is_has = **arg == 'h'; |
28287
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
953 int is_len = **arg == 'l'; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 argvars[0].v_type = VAR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 if (*s == '"') |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
957 (void)eval_string(&s, &argvars[0], TRUE, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 else if (*s == '\'') |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
959 (void)eval_lit_string(&s, &argvars[0], TRUE, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 s = skipwhite(s); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 if (*s == ')' && argvars[0].v_type == VAR_STRING |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 && ((is_has && !dynamic_feature(argvars[0].vval.v_string)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 || !is_has)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 *arg = s + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 argvars[1].v_type = VAR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 tv->v_type = VAR_NUMBER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 tv->vval.v_number = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 if (is_has) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 f_has(argvars, tv); |
28287
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
973 else if (is_len) |
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
974 f_len(argvars, tv); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 f_exists(argvars, tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 clear_tv(&argvars[0]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 ++ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 clear_tv(&argvars[0]); |
28287
dc68c111cf7a
patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents:
28271
diff
changeset
|
982 if (!is_has && !is_len) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 emsg(_(e_argument_of_exists_compiled_must_be_literal_string)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 |
31982
9113d903a2c6
patch 9.0.1323: build failure with +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
992 funcerror_T error; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 name = fname_trans_sid(namebuf, fname_buf, &tofree, &error); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 // We handle the "skip" argument of searchpair() and searchpairpos() |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 // differently. |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
997 if ((varlen == 6 && STRNCMP(*arg, "search", 6) == 0) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
998 || (varlen == 9 && STRNCMP(*arg, "searchpos", 9) == 0) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
999 || (varlen == 10 && STRNCMP(*arg, "searchpair", 10) == 0) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1000 || (varlen == 13 && STRNCMP(*arg, "searchpairpos", 13) == 0)) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1001 special_fn = CA_SEARCHPAIR; |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1002 else if (varlen == 10 && STRNCMP(*arg, "substitute", 10) == 0) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1003 special_fn = CA_SUBSTITUTE; |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1004 else |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1005 special_fn = CA_NOT_SPECIAL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 *arg = skipwhite(*arg + varlen + 1); |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1008 if (compile_arguments(arg, cctx, &argcount, special_fn) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 is_autoload = vim_strchr(name, AUTOLOAD_CHAR) != NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 if (ASCII_ISLOWER(*name) && name[1] != ':' && !is_autoload) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 // builtin function |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 idx = find_internal_func(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 if (STRCMP(name, "flatten") == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 emsg(_(e_cannot_use_flatten_in_vim9_script)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 if (STRCMP(name, "add") == 0 && argcount == 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 { |
27505
29104ffb4dca
patch 8.2.4280: list-dict test crashes
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
1028 type_T *type = get_decl_type_on_stack(cctx, 1); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 // add() can be compiled to instructions if we know the type |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 if (type->tt_type == VAR_LIST) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 // inline "add(list, item)" so that the type can be checked |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 res = generate_LISTAPPEND(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 idx = -1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 else if (type->tt_type == VAR_BLOB) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 // inline "add(blob, nr)" so that the type can be checked |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 res = generate_BLOBAPPEND(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 idx = -1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 |
30209
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
1045 if ((STRCMP(name, "writefile") == 0 && argcount > 2) |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
1046 || (STRCMP(name, "mkdir") == 0 && argcount > 1)) |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1047 { |
30209
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
1048 // May have the "D" or "R" flag, reserve a variable for a |
a970b48c25a3
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
1049 // deferred function call. |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1050 if (get_defer_var_idx(cctx) == 0) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1051 idx = -1; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1052 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1053 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 res = generate_BCALL(cctx, idx, argcount, argcount_init == 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 else |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1058 emsg_funcname(e_unknown_function_str, namebuf); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1062 has_g_namespace = STRNCMP(namebuf, "g:", 2) == 0; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1063 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 // An argument or local variable can be a function reference, this |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 // overrules a function name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 if (lookup_local(namebuf, varlen, NULL, cctx) == FAIL |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 && arg_exists(namebuf, varlen, NULL, NULL, NULL, cctx) != OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 // If we can find the function by name generate the right call. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 // Skip global functions here, a local funcref takes precedence. |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
1071 ufunc = find_func(name, FALSE); |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1072 if (ufunc != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 { |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1074 if (!func_is_global(ufunc)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1075 { |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1076 res = generate_CALL(cctx, ufunc, NULL, 0, argcount); |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1077 goto theend; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1078 } |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1079 if (!has_g_namespace |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1080 && vim_strchr(ufunc->uf_name, AUTOLOAD_CHAR) == NULL) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1081 { |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1082 // A function name without g: prefix must be found locally. |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1083 emsg_funcname(e_unknown_function_str, namebuf); |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1084 goto theend; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1085 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 // If the name is a variable, load it and use PCALL. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 // Not for g:Func(), we don't know if it is a variable or not. |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1091 // Not for some#Func(), it will be loaded later. |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 p = namebuf; |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1093 if (!has_g_namespace && !is_autoload |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 && compile_load(&p, namebuf + varlen, cctx, FALSE, FALSE) == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
1096 type_T *type = get_type_on_stack(cctx, 0); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 res = generate_PCALL(cctx, argcount, namebuf, type, FALSE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 // If we can find a global function by name generate the right call. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 if (ufunc != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 { |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1105 res = generate_CALL(cctx, ufunc, NULL, 0, argcount); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 // A global function may be defined only later. Need to figure out at |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 // runtime. Also handles a FuncRef at runtime. |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1111 if (has_g_namespace || is_autoload) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 res = generate_UCALL(cctx, name, argcount); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 else |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1114 emsg_funcname(e_unknown_function_str, namebuf); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 theend: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 vim_free(tofree); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 return res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 // like NAMESPACE_CHAR but with 'a' and 'l'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 #define VIM9_NAMESPACE_CHAR (char_u *)"bgstvw" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 * Find the end of a variable or function name. Unlike find_name_end() this |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 * does not recognize magic braces. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 * When "use_namespace" is TRUE recognize "b:", "s:", etc. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 * Return a pointer to just after the name. Equal to "arg" if there is no |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 * valid name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 char_u * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 to_name_end(char_u *arg, int use_namespace) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 // Quick check for valid starting character. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 if (!eval_isnamec1(*arg)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 return arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 for (p = arg + 1; *p != NUL && eval_isnamec(*p); MB_PTR_ADV(p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 // Include a namespace such as "s:var" and "v:var". But "n:" is not |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 // and can be used in slice "[n:]". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 if (*p == ':' && (p != arg + 1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 || !use_namespace |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 || vim_strchr(VIM9_NAMESPACE_CHAR, *arg) == NULL)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 return p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 * Like to_name_end() but also skip over a list or dict constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 * Also accept "<SNR>123_Func". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 * This intentionally does not handle line continuation. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 char_u * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 to_name_const_end(char_u *arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 char_u *p = arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 if (STRNCMP(p, "<SNR>", 5) == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 p = skipdigits(p + 5); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 p = to_name_end(p, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 if (p == arg && *arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 // Can be "[1, 2, 3]->Func()". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 if (eval_list(&p, &rettv, NULL, FALSE) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 p = arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 return p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 * parse a list: [expr, expr] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 * "*arg" points to the '['. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 * ppconst->pp_is_const is set if all items are a constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 char_u *p = skipwhite(*arg + 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 char_u *whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 int count = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 int is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 int is_all_const = TRUE; // reset when non-const encountered |
29782
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1187 int must_end = FALSE; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 if (may_get_next_line(whitep, &p, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26769
diff
changeset
|
1193 semsg(_(e_missing_end_of_list_rsb_str), *arg); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 semsg(_(e_no_white_space_allowed_before_str_str), ",", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 if (*p == ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 } |
29782
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1206 if (must_end) |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1207 { |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1208 semsg(_(e_missing_comma_in_list_str), p); |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1209 return FAIL; |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1210 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 if (compile_expr0_ext(&p, cctx, &is_const) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 if (!is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 is_all_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 ++count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 if (*p != ']' && !IS_WHITE_OR_NUL(*p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 semsg(_(e_white_space_required_after_str_str), ",", p - 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 } |
29782
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1225 else |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1226 must_end = TRUE; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 whitep = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 *arg = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 ppconst->pp_is_const = is_all_const; |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
1233 return generate_NEWLIST(cctx, count, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 * Parse a lambda: "(arg, arg) => expr" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 * "*arg" points to the '('. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 * Returns OK/FAIL when a lambda is recognized, NOTDONE if it's not a lambda. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 compile_lambda(char_u **arg, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 ufunc_T *ufunc; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 evalarg_T evalarg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 init_evalarg(&evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 evalarg.eval_flags = EVAL_EVALUATE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 evalarg.eval_cctx = cctx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 // Get the funcref in "rettv". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 r = get_lambda_tv(arg, &rettv, TRUE, &evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 if (r != OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 return r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 // "rettv" will now be a partial referencing the function. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 ufunc = rettv.vval.v_partial->pt_func; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 ++ufunc->uf_refcount; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 clear_tv(&rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 // Compile it here to get the return type. The return type is optional, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 // when it's missing use t_unknown. This is recognized in |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 // compile_return(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 if (ufunc->uf_ret_type->tt_type == VAR_VOID) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 ufunc->uf_ret_type = &t_unknown; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 compile_def_function(ufunc, FALSE, cctx->ctx_compile_type, cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 // When the outer function is compiled for profiling or debugging, the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 // lambda may be called without profiling or debugging. Compile it here in |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 // the right context. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 if (cctx->ctx_compile_type == CT_DEBUG |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 #ifdef FEAT_PROFILE |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 || cctx->ctx_compile_type == CT_PROFILE |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 #endif |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 ) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 compile_def_function(ufunc, FALSE, CT_NONE, cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1283 // if the outer function is not compiled for debugging or profiling, this |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1284 // one might be |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1285 if (cctx->ctx_compile_type == CT_NONE) |
28097
632a84e2ce92
patch 8.2.4573: a nested function is compiled for debugging without context
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
1286 { |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1287 compiletype_T compile_type = get_compile_type(ufunc); |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1288 |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1289 if (compile_type != CT_NONE) |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1290 compile_def_function(ufunc, FALSE, compile_type, cctx); |
28097
632a84e2ce92
patch 8.2.4573: a nested function is compiled for debugging without context
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
1291 } |
632a84e2ce92
patch 8.2.4573: a nested function is compiled for debugging without context
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
1292 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 // The last entry in evalarg.eval_tofree_ga is a copy of the last line and |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 // "*arg" may point into it. Point into the original line to avoid a |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 // dangling pointer. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 if (evalarg.eval_using_cmdline) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 garray_T *gap = &evalarg.eval_tofree_ga; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 size_t off = *arg - ((char_u **)gap->ga_data)[gap->ga_len - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 *arg = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 + off; |
30437
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
1303 evalarg.eval_using_cmdline = FALSE; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 if (ufunc->uf_def_status == UF_COMPILED) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 // The return type will now be known. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 set_function_type(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 // The function reference count will be 1. When the ISN_FUNCREF |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 // instruction is deleted the reference count is decremented and the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 // function is freed. |
31920
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
1316 return generate_FUNCREF(cctx, ufunc, NULL, 0, NULL); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 func_ptr_unref(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 * Get a lambda and compile it. Uses Vim9 syntax. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 get_lambda_tv_and_compile( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 typval_T *rettv, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 int types_optional, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 evalarg_T *evalarg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 ufunc_T *ufunc; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 int save_sc_version = current_sctx.sc_version; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 // Get the funcref in "rettv". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 current_sctx.sc_version = SCRIPT_VERSION_VIM9; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 r = get_lambda_tv(arg, rettv, types_optional, evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 current_sctx.sc_version = save_sc_version; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 if (r != OK) |
28846
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
1342 return r; // currently unreachable |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 // "rettv" will now be a partial referencing the function. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 ufunc = rettv->vval.v_partial->pt_func; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 // Compile it here to get the return type. The return type is optional, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 // when it's missing use t_unknown. This is recognized in |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 // compile_return(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 if (ufunc->uf_ret_type == NULL || ufunc->uf_ret_type->tt_type == VAR_VOID) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 ufunc->uf_ret_type = &t_unknown; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 compile_def_function(ufunc, FALSE, CT_NONE, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 if (ufunc->uf_def_status == UF_COMPILED) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 // The return type will now be known. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 set_function_type(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 * parse a dict: {key: val, [key]: val} |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 * "*arg" points to the '{'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 * ppconst->pp_is_const is set if all item values are a constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 garray_T *instr = &cctx->ctx_instr; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 int count = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 dict_T *d = dict_alloc(); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 dictitem_T *item; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 char_u *whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 int is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 int is_all_const = TRUE; // reset when non-const encountered |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 if (d == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 char_u *key = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 if (may_get_next_line(whitep, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 if (**arg == '}') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 if (**arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 isn_T *isn; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 // {[expr]: value} uses an evaluated key. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 *arg = skipwhite(*arg + 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 if (compile_expr0(arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 if (isn->isn_type == ISN_PUSHNR) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 char buf[NUMBUFLEN]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 // Convert to string at compile time. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 vim_snprintf(buf, NUMBUFLEN, "%lld", isn->isn_arg.number); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 isn->isn_type = ISN_PUSHS; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 isn->isn_arg.string = vim_strsave((char_u *)buf); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 if (isn->isn_type == ISN_PUSHS) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 key = isn->isn_arg.string; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 else if (may_generate_2STRING(-1, FALSE, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 if (**arg != ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 emsg(_(e_missing_matching_bracket_after_dict_key)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 // {"name": value}, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 // {'name': value}, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 // {name: value} use "name" as a literal key |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 key = get_literal_key(arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 if (key == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 if (generate_PUSHS(cctx, &key) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 // Check for duplicate keys, if using string keys. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 if (key != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 item = dict_find(d, key, -1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 if (item != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1446 semsg(_(e_duplicate_key_in_dictionary_str), key); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 item = dictitem_alloc(key); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 if (item != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 item->di_tv.v_type = VAR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 item->di_tv.v_lock = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 if (dict_add(d, item) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 dictitem_free(item); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 if (**arg != ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 if (*skipwhite(*arg) == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 semsg(_(e_no_white_space_allowed_before_str_str), ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 else |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1464 semsg(_(e_missing_colon_in_dictionary_str), *arg); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 if (!IS_WHITE_OR_NUL(*whitep)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 semsg(_(e_white_space_required_after_str_str), ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 if (may_get_next_line(whitep, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 if (compile_expr0_ext(arg, cctx, &is_const) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 if (!is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 is_all_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 ++count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 whitep = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 if (may_get_next_line(whitep, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 if (**arg == '}') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 if (**arg != ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1496 semsg(_(e_missing_comma_in_dictionary_str), *arg); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 if (IS_WHITE_OR_NUL(*whitep)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 semsg(_(e_no_white_space_allowed_before_str_str), ",", whitep); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 if (!IS_WHITE_OR_NUL(*whitep)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 semsg(_(e_white_space_required_after_str_str), ",", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 *arg = skipwhite(whitep); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 *arg = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 // Allow for following comment, after at least one space. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 if (VIM_ISWHITE(**arg) && vim9_comment_start(p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 *arg += STRLEN(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 dict_unref(d); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 ppconst->pp_is_const = is_all_const; |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
1522 return generate_NEWDICT(cctx, count, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 failret: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 if (*arg == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1527 semsg(_(e_missing_dict_end_str), _("[end of lines]")); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 *arg = (char_u *)""; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 dict_unref(d); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 * Compile "&option". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 compile_get_option(char_u **arg, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 char_u *start = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 // parse the option and get the current value to get the type. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 rettv.v_type = VAR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 ret = eval_option(arg, &rettv, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 if (ret == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 // include the '&' in the name, eval_option() expects it. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 char_u *name = vim_strnsave(start, *arg - start); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 type_T *type = rettv.v_type == VAR_BOOL ? &t_bool |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 : rettv.v_type == VAR_NUMBER ? &t_number : &t_string; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 ret = generate_LOAD(cctx, ISN_LOADOPT, 0, name, type); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 clear_tv(&rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 * Compile "$VAR". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 compile_get_env(char_u **arg, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 char_u *start = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 int len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 char_u *name; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 len = get_env_len(arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 if (len == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 { |
27041
fc19375787dd
patch 8.2.4049: Vim9: reading before the start of the line with "$"
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
1577 semsg(_(e_syntax_error_at_str), start); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1581 // include the '$' in the name, eval_env_var() expects it. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 name = vim_strnsave(start, len + 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 ret = generate_LOAD(cctx, ISN_LOADENV, 0, name, &t_string); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 /* |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1589 * Compile $"string" or $'string'. |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1590 */ |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1591 static int |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1592 compile_interp_string(char_u **arg, cctx_T *cctx) |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1593 { |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1594 typval_T tv; |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1595 int ret; |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1596 int quote; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1597 int evaluate = cctx->ctx_skip != SKIP_YES; |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1598 int count = 0; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1599 char_u *p; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1600 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1601 // *arg is on the '$' character, move it to the first string character. |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1602 ++*arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1603 quote = **arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1604 ++*arg; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1605 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1606 for (;;) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1607 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1608 // Get the string up to the matching quote or to a single '{'. |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1609 // "arg" is advanced to either the quote or the '{'. |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1610 if (quote == '"') |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1611 ret = eval_string(arg, &tv, evaluate, TRUE); |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1612 else |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1613 ret = eval_lit_string(arg, &tv, evaluate, TRUE); |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1614 if (ret == FAIL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1615 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1616 if (evaluate) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1617 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1618 if ((tv.vval.v_string != NULL && *tv.vval.v_string != NUL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1619 || (**arg != '{' && count == 0)) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1620 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1621 // generate non-empty string or empty string if it's the only |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1622 // one |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1623 if (generate_PUSHS(cctx, &tv.vval.v_string) == FAIL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1624 return FAIL; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1625 tv.vval.v_string = NULL; // don't free it now |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1626 ++count; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1627 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1628 clear_tv(&tv); |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1629 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1630 |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1631 if (**arg != '{') |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1632 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1633 // found terminating quote |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1634 ++*arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1635 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1636 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1637 |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1638 p = compile_one_expr_in_str(*arg, cctx); |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1639 if (p == NULL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1640 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1641 ret = FAIL; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1642 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1643 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1644 ++count; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1645 *arg = p; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1646 } |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1647 |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1648 if (ret == FAIL || !evaluate) |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1649 return ret; |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1650 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1651 // Small optimization, if there's only a single piece skip the ISN_CONCAT. |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1652 if (count > 1) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1653 return generate_CONCAT(cctx, count); |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1654 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1655 return OK; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1656 } |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1657 |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1658 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 * Compile "@r". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 compile_get_register(char_u **arg, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 if (**arg == NUL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 semsg(_(e_syntax_error_at_str), *arg - 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 if (!valid_yank_reg(**arg, FALSE)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 emsg_invreg(**arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 ret = generate_LOAD(cctx, ISN_LOADREG, **arg, NULL, &t_string); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 * Apply leading '!', '-' and '+' to constant "rettv". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1684 * When "numeric_only" is TRUE do not apply '!'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1685 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 apply_leader(typval_T *rettv, int numeric_only, char_u *start, char_u **end) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1688 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1689 char_u *p = *end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 // this works from end to start |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 while (p > start) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 if (*p == '-' || *p == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1696 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 // only '-' has an effect, for '+' we only check the type |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 if (rettv->v_type == VAR_FLOAT) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1699 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 if (*p == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1701 rettv->vval.v_float = -rettv->vval.v_float; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1702 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 varnumber_T val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 int error = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 // tv_get_number_chk() accepts a string, but we don't want that |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 // here |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 if (check_not_string(rettv) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1711 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 val = tv_get_number_chk(rettv, &error); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 if (error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1716 if (*p == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 val = -val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 rettv->v_type = VAR_NUMBER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 rettv->vval.v_number = val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 else if (numeric_only) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1727 else if (*p == '!') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1729 int v = tv2bool(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 // '!' is permissive in the type. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 rettv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 rettv->vval.v_number = v ? VVAL_FALSE : VVAL_TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 *end = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 * Recognize v: variables that are constants and set "rettv". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 static void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 get_vim_constant(char_u **arg, typval_T *rettv) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 if (STRNCMP(*arg, "v:true", 6) == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 rettv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 rettv->vval.v_number = VVAL_TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1751 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 else if (STRNCMP(*arg, "v:false", 7) == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1754 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1755 rettv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 rettv->vval.v_number = VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 *arg += 7; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 else if (STRNCMP(*arg, "v:null", 6) == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 rettv->v_type = VAR_SPECIAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 rettv->vval.v_number = VVAL_NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1765 else if (STRNCMP(*arg, "v:none", 6) == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 rettv->v_type = VAR_SPECIAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 rettv->vval.v_number = VVAL_NONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 exprtype_T |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 get_compare_type(char_u *p, int *len, int *type_is) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 exprtype_T type = EXPR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 switch (p[0]) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 case '=': if (p[1] == '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 type = EXPR_EQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 else if (p[1] == '~') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 type = EXPR_MATCH; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 case '!': if (p[1] == '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 type = EXPR_NEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 else if (p[1] == '~') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 type = EXPR_NOMATCH; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 case '>': if (p[1] != '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 type = EXPR_GREATER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 *len = 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 type = EXPR_GEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 case '<': if (p[1] != '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 type = EXPR_SMALLER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 *len = 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 type = EXPR_SEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 case 'i': if (p[1] == 's') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 // "is" and "isnot"; but not a prefix of a name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 *len = 5; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 i = p[*len]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 if (!isalnum(i) && i != '_') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1814 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 type = *len == 2 ? EXPR_IS : EXPR_ISNOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 *type_is = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 return type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 * Skip over an expression, ignoring most errors. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1828 skip_expr_cctx(char_u **arg, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 evalarg_T evalarg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1832 init_evalarg(&evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 evalarg.eval_cctx = cctx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 skip_expr(arg, &evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1835 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 * Check that the top of the type stack has a type that can be used as a |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 * condition. Give an error and return FAIL if not. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 bool_on_stack(cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 type_T *type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
1847 type = get_type_on_stack(cctx, 0); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 if (type == &t_bool) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1850 |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1851 if (type->tt_type == VAR_ANY |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1852 || type->tt_type == VAR_UNKNOWN |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1853 || type->tt_type == VAR_NUMBER |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1854 || type == &t_number_bool |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1855 || type == &t_const_number_bool) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 // Number 0 and 1 are OK to use as a bool. "any" could also be a bool. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 // This requires a runtime type check. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 return generate_COND2BOOL(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
1860 return need_type(type, &t_bool, FALSE, -1, 0, cctx, FALSE, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 * Give the "white on both sides" error, taking the operator from "p[len]". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 error_white_both(char_u *op, int len) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 char_u buf[10]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 vim_strncpy(buf, op, len); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 semsg(_(e_white_space_required_before_and_after_str_at_str), buf, op); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1873 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 * Compile code to apply '-', '+' and '!'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 * When "numeric_only" is TRUE do not apply '!'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 char_u *p = *end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 // this works from end to start |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 while (p > start) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1887 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1888 while (VIM_ISWHITE(*p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 if (*p == '-' || *p == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1891 { |
31549
6f1cbee3d652
patch 9.0.1107: float constant not recognized as float
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
1892 type_T *type = get_type_on_stack(cctx, 0); |
6f1cbee3d652
patch 9.0.1107: float constant not recognized as float
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
1893 if (type->tt_type != VAR_FLOAT && need_type(type, &t_number, |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
1894 FALSE, -1, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1897 // only '-' has an effect, for '+' we only check the type |
31549
6f1cbee3d652
patch 9.0.1107: float constant not recognized as float
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
1898 if (*p == '-' && generate_instr(cctx, ISN_NEGATENR) == NULL) |
6f1cbee3d652
patch 9.0.1107: float constant not recognized as float
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
1899 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 else if (numeric_only) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1904 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1907 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 int invert = *p == '!'; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1909 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1910 while (p > start && (p[-1] == '!' || VIM_ISWHITE(p[-1]))) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 if (p[-1] == '!') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1913 invert = !invert; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 if (generate_2BOOL(cctx, invert, -1) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 *end = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 * Compile "(expression)": recursive! |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 * Return FAIL/OK. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 compile_parenthesis(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 char_u *p = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1933 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1934 if (may_get_next_line_error(p, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 if (ppconst->pp_used <= PPSIZE - 10) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 ret = compile_expr1(arg, cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 // Not enough space in ppconst, flush constants. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 ret = compile_expr0(arg, cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1946 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 if (may_get_next_line_error(*arg, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1948 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 if (**arg == ')') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 else if (ret == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1952 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 emsg(_(e_missing_closing_paren)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1954 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1956 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1958 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1959 static int compile_expr9(char_u **arg, cctx_T *cctx, ppconst_T *ppconst); |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
1960 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 * Compile whatever comes after "name" or "name()". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 * Advances "*arg" only when something was recognized. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 compile_subscript( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 char_u *start_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 char_u **end_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 char_u *name_start = *end_leader; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 int keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 char_u *p = skipwhite(*arg); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
1979 type_T *type; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 if (*p == NUL || (VIM_ISWHITE(**arg) && vim9_comment_start(p))) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 char_u *next = peek_next_line_from_context(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 |
30930
cbfbf0e17cd0
patch 9.0.0799: in compiled function ->() on next line not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30888
diff
changeset
|
1985 // If a following line starts with "->{", "->(" or "->X" advance to |
cbfbf0e17cd0
patch 9.0.0799: in compiled function ->() on next line not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30888
diff
changeset
|
1986 // that line, so that a line break before "->" is allowed. |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 // Also if a following line starts with ".x". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 if (next != NULL && |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 ((next[0] == '-' && next[1] == '>' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1990 && (next[2] == '{' |
30930
cbfbf0e17cd0
patch 9.0.0799: in compiled function ->() on next line not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30888
diff
changeset
|
1991 || next[2] == '(' |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 || ASCII_ISALPHA(*skipwhite(next + 2)))) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1993 || (next[0] == '.' && eval_isdictc(next[1])))) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1994 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 next = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 if (next == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 *arg = next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1999 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2000 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2001 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2003 // Do not skip over white space to find the "(", "execute 'x' (expr)" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 // is not a function call. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 if (**arg == '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2006 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 int argcount = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2008 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2009 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2010 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2011 ppconst->pp_is_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2012 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2013 // funcref(arg) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2014 type = get_type_on_stack(cctx, 0); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2015 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2016 *arg = skipwhite(p + 1); |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
2017 if (compile_arguments(arg, cctx, &argcount, CA_NOT_SPECIAL) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2019 if (generate_PCALL(cctx, argcount, name_start, type, TRUE) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 if (generate_instr(cctx, ISN_CLEARDICT) == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2027 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 else if (*p == '-' && p[1] == '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 { |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2030 char_u *pstart = p; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2031 int alt; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2032 char_u *paren; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2033 |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2034 // something->method() |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2035 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2036 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2037 ppconst->pp_is_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2039 // Apply the '!', '-' and '+' first: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 // -1.0->func() works like (-1.0)->func() |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2041 if (compile_leader(cctx, TRUE, start_leader, end_leader) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2044 p += 2; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 *arg = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2046 // No line break supported right after "->". |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2047 |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2048 // Three alternatives handled here: |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2049 // 1. "base->name(" only a name, use compile_call() |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2050 // 2. "base->(expr)(" evaluate "expr", then use PCALL |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2051 // 3. "base->expr(" Same, find the end of "expr" by "(" |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 if (**arg == '(') |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2053 alt = 2; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2054 else |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2055 { |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2056 // alternative 1 or 3 |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2057 p = *arg; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2058 if (!eval_isnamec1(*p)) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2059 { |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2060 semsg(_(e_trailing_characters_str), pstart); |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2061 return FAIL; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2062 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2063 if (ASCII_ISALPHA(*p) && p[1] == ':') |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2064 p += 2; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2065 for ( ; eval_isnamec(*p); ++p) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2066 ; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2067 if (*p == '(') |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2068 { |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2069 // alternative 1 |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2070 alt = 1; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2071 if (compile_call(arg, p - *arg, cctx, ppconst, 1) == FAIL) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2072 return FAIL; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2073 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2074 else |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2075 { |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2076 // Must be alternative 3, find the "(". Only works within |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2077 // one line. |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2078 alt = 3; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2079 paren = vim_strchr(p, '('); |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2080 if (paren == NULL) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2081 { |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2082 semsg(_(e_missing_parenthesis_str), *arg); |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2083 return FAIL; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2084 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2085 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2086 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2087 |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2088 if (alt != 1) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 int argcount = 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 garray_T *stack = &cctx->ctx_type_stack; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 int type_idx_start = stack->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2093 int expr_isn_start = cctx->ctx_instr.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 int expr_isn_end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2095 int arg_isn_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2096 |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2097 if (alt == 2) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2098 { |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2099 // Funcref call: list->(Refs[2])(arg) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2100 // or lambda: list->((arg) => expr)(arg) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2101 // |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2102 // Fist compile the function expression. |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2103 if (compile_parenthesis(arg, cctx, ppconst) == FAIL) |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2104 return FAIL; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2105 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2106 else |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2107 { |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2108 int fail; |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2109 int save_len = cctx->ctx_ufunc->uf_lines.ga_len; |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
2110 int prev_did_emsg = did_emsg; |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2111 |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2112 *paren = NUL; |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2113 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2114 // instead of using LOADG for "import.Func" use PUSHFUNC |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2115 ++paren_follows_after_expr; |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2116 |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2117 // do not look in the next line |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2118 cctx->ctx_ufunc->uf_lines.ga_len = 1; |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2119 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2120 fail = compile_expr9(arg, cctx, ppconst) == FAIL |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2121 || *skipwhite(*arg) != NUL; |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2122 *paren = '('; |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2123 --paren_follows_after_expr; |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2124 cctx->ctx_ufunc->uf_lines.ga_len = save_len; |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2125 |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2126 if (fail) |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2127 { |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
2128 if (did_emsg == prev_did_emsg) |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
2129 semsg(_(e_invalid_expression_str), pstart); |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2130 return FAIL; |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2131 } |
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2132 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 // Compile the arguments. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 if (**arg != '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 if (*skipwhite(*arg) == '(') |
26887
612339679616
patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
2138 emsg(_(e_no_white_space_allowed_before_parenthesis)); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 semsg(_(e_missing_parenthesis_str), *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2142 } |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2143 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2144 // Remember the next instruction index, where the instructions |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2145 // for arguments are being written. |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2146 expr_isn_end = cctx->ctx_instr.ga_len; |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2147 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2148 *arg = skipwhite(*arg + 1); |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
2149 if (compile_arguments(arg, cctx, &argcount, CA_NOT_SPECIAL) |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
2150 == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 // Move the instructions for the arguments to before the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 // instructions of the expression and move the type of the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2155 // expression after the argument types. This is what ISN_PCALL |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2156 // expects. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 arg_isn_count = cctx->ctx_instr.ga_len - expr_isn_end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2158 if (arg_isn_count > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2159 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 int expr_isn_count = expr_isn_end - expr_isn_start; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 isn_T *isn = ALLOC_MULT(isn_T, expr_isn_count); |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2162 type_T *decl_type; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2163 type2_T *typep; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2165 if (isn == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2167 mch_memmove(isn, ((isn_T *)cctx->ctx_instr.ga_data) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 + expr_isn_start, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2169 sizeof(isn_T) * expr_isn_count); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 mch_memmove(((isn_T *)cctx->ctx_instr.ga_data) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 + expr_isn_start, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 ((isn_T *)cctx->ctx_instr.ga_data) + expr_isn_end, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 sizeof(isn_T) * arg_isn_count); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 mch_memmove(((isn_T *)cctx->ctx_instr.ga_data) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 + expr_isn_start + arg_isn_count, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2176 isn, sizeof(isn_T) * expr_isn_count); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 vim_free(isn); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2178 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2179 typep = ((type2_T *)stack->ga_data) + type_idx_start; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2180 type = typep->type_curr; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2181 decl_type = typep->type_decl; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2182 mch_memmove(((type2_T *)stack->ga_data) + type_idx_start, |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2183 ((type2_T *)stack->ga_data) + type_idx_start + 1, |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2184 sizeof(type2_T) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2185 * (stack->ga_len - type_idx_start - 1)); |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2186 typep = ((type2_T *)stack->ga_data) + stack->ga_len - 1; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2187 typep->type_curr = type; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2188 typep->type_decl = decl_type; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2191 type = get_type_on_stack(cctx, 0); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 if (generate_PCALL(cctx, argcount, p - 2, type, FALSE) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2193 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2194 } |
27175
6af18c69c59d
patch 8.2.4116: Vim9: cannot use a method with a complex expression in :def
Bram Moolenaar <Bram@vim.org>
parents:
27114
diff
changeset
|
2195 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2196 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2197 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2199 if (generate_instr(cctx, ISN_CLEARDICT) == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2200 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2201 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2202 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2203 else if (**arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2204 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2205 int is_slice = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 // list index: list[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 // dict member: dict[key] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 // string index: text[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2210 // blob index: blob[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2211 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2212 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2213 ppconst->pp_is_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2214 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2215 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2216 if (may_get_next_line_error(p, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2217 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2218 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2219 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2220 // missing first index is equal to zero |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 generate_PUSHNR(cctx, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2222 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 if (compile_expr0(arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 semsg(_(e_white_space_required_before_and_after_str_at_str), |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2230 ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 if (may_get_next_line_error(*arg, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2236 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2238 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2239 is_slice = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2240 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2241 if (!IS_WHITE_OR_NUL(**arg) && **arg != ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2242 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2243 semsg(_(e_white_space_required_before_and_after_str_at_str), |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2244 ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2246 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 if (may_get_next_line_error(*arg, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 if (**arg == ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 // missing second index is equal to end of string |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 generate_PUSHNR(cctx, -1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 if (compile_expr0(arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2255 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2256 if (may_get_next_line_error(*arg, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2257 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2258 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2259 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2260 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2261 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2262 if (**arg != ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2263 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2264 emsg(_(e_missing_closing_square_brace)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2265 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2266 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2267 *arg = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2268 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2269 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2270 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2272 if (generate_instr(cctx, ISN_CLEARDICT) == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2274 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2275 if (compile_member(is_slice, &keeping_dict, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2276 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2277 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2278 else if (*p == '.' && p[1] != '.') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2279 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2280 // dictionary member: dict.name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2281 if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2282 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2283 ppconst->pp_is_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2284 |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2285 if ((type = get_type_on_stack(cctx, 0)) != &t_unknown |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2286 && (type->tt_type == VAR_CLASS |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2287 || type->tt_type == VAR_OBJECT)) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2288 { |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2289 // class member: SomeClass.varname |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2290 // class method: SomeClass.SomeMethod() |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2291 // class constructor: SomeClass.new() |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2292 // object member: someObject.varname, this.varname |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2293 // object method: someObject.SomeMethod(), this.SomeMethod() |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2294 *arg = p; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2295 if (compile_class_object_index(cctx, arg, type) == FAIL) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2296 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2297 } |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2298 else |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2299 { |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2300 *arg = p + 1; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2301 if (IS_WHITE_OR_NUL(**arg)) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2302 { |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2303 emsg(_(e_missing_name_after_dot)); |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2304 return FAIL; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2305 } |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2306 p = *arg; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2307 if (eval_isdictc(*p)) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2308 while (eval_isnamec(*p)) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2309 MB_PTR_ADV(p); |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2310 if (p == *arg) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2311 { |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2312 semsg(_(e_syntax_error_at_str), *arg); |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2313 return FAIL; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2314 } |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2315 if (keeping_dict && generate_instr(cctx, ISN_CLEARDICT) == NULL) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2316 return FAIL; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2317 if (generate_STRINGMEMBER(cctx, *arg, p - *arg) == FAIL) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2318 return FAIL; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2319 keeping_dict = TRUE; |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2320 *arg = p; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2321 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2322 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2323 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2324 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2325 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2326 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2327 // Turn "dict.Func" into a partial for "Func" bound to "dict". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2328 // This needs to be done at runtime to be able to check the type. |
28899
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28852
diff
changeset
|
2329 if (keeping_dict && cctx->ctx_skip != SKIP_YES |
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28852
diff
changeset
|
2330 && generate_instr(cctx, ISN_USEDICT) == NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2331 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2333 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2334 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2335 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2336 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2337 * Compile an expression at "*arg" and add instructions to "cctx->ctx_instr". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2338 * "arg" is advanced until after the expression, skipping white space. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2339 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2340 * If the value is a constant "ppconst->pp_used" will be non-zero. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2341 * Before instructions are generated, any values in "ppconst" will generated. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2342 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2343 * This is the compiling equivalent of eval1(), eval2(), etc. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2344 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2345 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2346 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2347 * number number constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2348 * 0zFFFFFFFF Blob constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2349 * "string" string constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 * 'string' literal string constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 * &option-name option value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2352 * @r register contents |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 * identifier variable value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 * function() function call |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2355 * $VAR environment variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 * (expression) nested expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2357 * [expr, expr] List |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 * {key: val, [key]: val} Dictionary |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2359 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2360 * Also handle: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2361 * ! in front logical NOT |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2362 * - in front unary minus |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2363 * + in front unary plus (ignored) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2364 * trailing (arg) funcref/partial call |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2365 * trailing [] subscript in String or List |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2366 * trailing .name entry in Dictionary |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2367 * trailing ->name() method call |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2368 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2369 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2370 compile_expr9( |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2371 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2373 ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2374 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2375 char_u *start_leader, *end_leader; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2376 int ret = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2377 typval_T *rettv = &ppconst->pp_tv[ppconst->pp_used]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2378 int used_before = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2379 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2380 ppconst->pp_is_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2381 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2382 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 * Skip '!', '-' and '+' characters. They are handled later. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2384 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2385 start_leader = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2386 if (eval_leader(arg, TRUE) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2387 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 end_leader = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2389 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 rettv->v_type = VAR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2391 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2392 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2393 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2394 * Number constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2395 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2396 case '0': // also for blob starting with 0z |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 case '1': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2398 case '2': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2399 case '3': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2400 case '4': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2401 case '5': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2402 case '6': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2403 case '7': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2404 case '8': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2405 case '9': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 case '.': if (eval_number(arg, rettv, TRUE, FALSE) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2408 // Apply "-" and "+" just before the number now, right to |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2409 // left. Matters especially when "->" follows. Stops at |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 // '!'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2411 if (apply_leader(rettv, TRUE, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2412 start_leader, &end_leader) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2413 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2414 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2415 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2417 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2418 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2419 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2420 * String constant: "string". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2421 */ |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
2422 case '"': if (eval_string(arg, rettv, TRUE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2423 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2424 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2426 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2427 * Literal string constant: 'str''ing'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2428 */ |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
2429 case '\'': if (eval_lit_string(arg, rettv, TRUE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2430 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2431 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2432 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2433 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2434 * Constant Vim variable. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2435 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2436 case 'v': get_vim_constant(arg, rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2437 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2438 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2439 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2440 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2441 * "true" constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2442 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2443 case 't': if (STRNCMP(*arg, "true", 4) == 0 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2444 && !eval_isnamec((*arg)[4])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2445 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2446 *arg += 4; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2447 rettv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2448 rettv->vval.v_number = VVAL_TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2449 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2450 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2451 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2452 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2453 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2454 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2455 * "false" constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2456 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2457 case 'f': if (STRNCMP(*arg, "false", 5) == 0 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2458 && !eval_isnamec((*arg)[5])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2459 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2460 *arg += 5; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 rettv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 rettv->vval.v_number = VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2463 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2464 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2466 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2467 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2468 /* |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2469 * "null" or "null_*" constant |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2470 */ |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2471 case 'n': if (STRNCMP(*arg, "null", 4) == 0) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2472 { |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2473 char_u *p = *arg + 4; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2474 int len; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2475 |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2476 for (len = 0; eval_isnamec(p[len]); ++len) |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2477 ; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2478 ret = handle_predefined(*arg, len + 4, rettv); |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2479 if (ret == FAIL) |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2480 ret = NOTDONE; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2481 else |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2482 *arg += len + 4; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2483 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2484 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2485 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2486 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2487 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2488 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2489 * List: [expr, expr] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2490 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2491 case '[': if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2492 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2493 ret = compile_list(arg, cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2494 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2495 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2496 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2497 * Dictionary: {'key': val, 'key': val} |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2498 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2499 case '{': if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2500 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2501 ret = compile_dict(arg, cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2502 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2503 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2504 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2505 * Option value: &name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2506 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2507 case '&': if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2508 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2509 ret = compile_get_option(arg, cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2510 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2511 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2512 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2513 * Environment variable: $VAR. |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2514 * Interpolated string: $"string" or $'string'. |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2515 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2516 case '$': if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2517 return FAIL; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2518 if ((*arg)[1] == '"' || (*arg)[1] == '\'') |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2519 ret = compile_interp_string(arg, cctx); |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2520 else |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2521 ret = compile_get_env(arg, cctx); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2522 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2523 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2524 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2525 * Register contents: @r. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2526 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2527 case '@': if (generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2528 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2529 ret = compile_get_register(arg, cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2530 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2531 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2532 * nested expression: (expression). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2533 * lambda: (arg, arg) => expr |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2534 * funcref: (arg, arg) => { statement } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2535 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2536 case '(': // if compile_lambda returns NOTDONE then it must be (expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2537 ret = compile_lambda(arg, cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2538 if (ret == NOTDONE) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2539 ret = compile_parenthesis(arg, cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2540 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2541 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2542 default: ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2543 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2544 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2545 if (ret == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2546 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2547 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2548 if (rettv->v_type != VAR_UNKNOWN && used_before == ppconst->pp_used) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2549 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2550 if (cctx->ctx_skip == SKIP_YES) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2551 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2552 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2553 // A constant expression can possibly be handled compile time, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2554 // return the value instead of generating code. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2555 ++ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2556 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2557 else if (ret == NOTDONE) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2558 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2559 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2560 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2561 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2562 if (!eval_isnamec1(**arg)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2563 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2564 if (!vim9_bad_comment(*arg)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2565 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2566 if (ends_excmd(*skipwhite(*arg))) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2567 semsg(_(e_empty_expression_str), *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2568 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2569 semsg(_(e_name_expected_str), *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2570 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2571 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2572 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2573 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2574 // "name" or "name()" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2575 p = to_name_end(*arg, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2576 if (p - *arg == (size_t)1 && **arg == '_') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2577 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2578 emsg(_(e_cannot_use_underscore_here)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2579 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2580 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2581 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2582 if (*p == '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2583 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2584 r = compile_call(arg, p - *arg, cctx, ppconst, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2585 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2586 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2587 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2588 if (cctx->ctx_skip != SKIP_YES |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2589 && generate_ppconst(cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2590 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2591 r = compile_load(arg, p, cctx, TRUE, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2592 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2593 if (r == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2594 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2595 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2596 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2597 // Handle following "[]", ".member", etc. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2598 // Then deal with prefixed '-', '+' and '!', if not done already. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2599 if (compile_subscript(arg, cctx, start_leader, &end_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2600 ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2601 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2602 if (ppconst->pp_used > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2603 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2604 // apply the '!', '-' and '+' before the constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2605 rettv = &ppconst->pp_tv[ppconst->pp_used - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 if (apply_leader(rettv, FALSE, start_leader, &end_leader) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2607 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2608 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2609 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2610 if (compile_leader(cctx, FALSE, start_leader, &end_leader) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2611 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2612 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2613 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2614 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2615 /* |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2616 * <type>expr9: runtime type check / conversion |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2617 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2619 compile_expr8(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2620 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 type_T *want_type = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2622 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 // Recognize <type> |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2624 if (**arg == '<' && eval_isnamec1((*arg)[1])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2626 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2627 want_type = parse_type(arg, cctx->ctx_type_list, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2628 if (want_type == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 if (**arg != '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2632 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 if (*skipwhite(*arg) == '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 semsg(_(e_no_white_space_allowed_before_str_str), ">", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2635 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2636 emsg(_(e_missing_gt)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2637 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2638 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2640 if (may_get_next_line_error(*arg, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2641 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2642 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2643 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2644 if (compile_expr9(arg, cctx, ppconst) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2646 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 if (want_type != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2648 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 type_T *actual; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2650 where_T where = WHERE_INIT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2652 generate_ppconst(cctx, ppconst); |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2653 actual = get_type_on_stack(cctx, 0); |
26674
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26662
diff
changeset
|
2654 if (check_type_maybe(want_type, actual, FALSE, where) != OK) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 { |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
2656 if (need_type(actual, want_type, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
2657 -1, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2658 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2659 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2660 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 * * number multiplication |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 * / number division |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 * % number modulo |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2669 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2670 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2671 compile_expr7(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2673 char_u *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 int ppconst_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2676 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 // get the first expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2678 if (compile_expr8(arg, cctx, ppconst) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 * Repeat computing, until no "*", "/" or "%" is following. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2686 op = may_peek_next_line(cctx, *arg, &next); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2687 if (*op != '*' && *op != '/' && *op != '%') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2689 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2690 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 *arg = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2692 op = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2693 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[1])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2697 error_white_both(op, 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2698 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2700 if (may_get_next_line_error(op + 1, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2701 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2703 // get the second expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2704 if (compile_expr8(arg, cctx, ppconst) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 if (ppconst->pp_used == ppconst_used + 2 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 && ppconst->pp_tv[ppconst_used].v_type == VAR_NUMBER |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 && ppconst->pp_tv[ppconst_used + 1].v_type == VAR_NUMBER) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2710 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2711 typval_T *tv1 = &ppconst->pp_tv[ppconst_used]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2712 typval_T *tv2 = &ppconst->pp_tv[ppconst_used + 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 varnumber_T res = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2714 int failed = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2715 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2716 // both are numbers: compute the result |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2717 switch (*op) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2718 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2719 case '*': res = tv1->vval.v_number * tv2->vval.v_number; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2720 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2721 case '/': res = num_divide(tv1->vval.v_number, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2722 tv2->vval.v_number, &failed); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2724 case '%': res = num_modulus(tv1->vval.v_number, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 tv2->vval.v_number, &failed); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2726 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2727 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2728 if (failed) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2729 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 tv1->vval.v_number = res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2731 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2732 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2734 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2735 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 generate_two_op(cctx, op); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2737 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2738 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2739 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2740 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2741 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2743 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2744 * + number addition or list/blobl concatenation |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2745 * - number subtraction |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2746 * .. string concatenation |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2747 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2748 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2749 compile_expr6(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2750 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2751 char_u *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2752 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2753 int oplen; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2754 int ppconst_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2755 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2756 // get the first variable |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2757 if (compile_expr7(arg, cctx, ppconst) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2758 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2759 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2760 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 * Repeat computing, until no "+", "-" or ".." is following. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2763 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2764 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2765 op = may_peek_next_line(cctx, *arg, &next); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2766 if (*op != '+' && *op != '-' && !(*op == '.' && *(op + 1) == '.')) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2767 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 if (op[0] == op[1] && *op != '.' && next) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2769 // Finding "++" or "--" on the next line is a separate command. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 // But ".." is concatenation. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2771 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 oplen = (*op == '.' ? 2 : 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2773 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2774 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 *arg = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2776 op = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2777 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2778 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2779 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2780 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2781 error_white_both(op, oplen); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2782 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2783 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2784 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2785 if (may_get_next_line_error(op + oplen, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2786 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2787 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2788 // get the second expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2789 if (compile_expr7(arg, cctx, ppconst) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2790 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2791 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2792 if (ppconst->pp_used == ppconst_used + 2 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2793 && (*op == '.' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2794 ? (ppconst->pp_tv[ppconst_used].v_type == VAR_STRING |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2795 && ppconst->pp_tv[ppconst_used + 1].v_type == VAR_STRING) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2796 : (ppconst->pp_tv[ppconst_used].v_type == VAR_NUMBER |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2797 && ppconst->pp_tv[ppconst_used + 1].v_type == VAR_NUMBER))) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2798 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2799 typval_T *tv1 = &ppconst->pp_tv[ppconst_used]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 typval_T *tv2 = &ppconst->pp_tv[ppconst_used + 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2801 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2802 // concat/subtract/add constant numbers |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2803 if (*op == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2804 tv1->vval.v_number = tv1->vval.v_number + tv2->vval.v_number; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2805 else if (*op == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 tv1->vval.v_number = tv1->vval.v_number - tv2->vval.v_number; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2807 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2808 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2809 // concatenate constant strings |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2810 char_u *s1 = tv1->vval.v_string; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 char_u *s2 = tv2->vval.v_string; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2812 size_t len1 = STRLEN(s1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2813 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2814 tv1->vval.v_string = alloc((int)(len1 + STRLEN(s2) + 1)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2815 if (tv1->vval.v_string == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2816 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2817 clear_ppconst(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2818 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2819 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2820 mch_memmove(tv1->vval.v_string, s1, len1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2821 STRCPY(tv1->vval.v_string + len1, s2); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2822 vim_free(s1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2823 vim_free(s2); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2824 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2825 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2826 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2828 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2829 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2830 ppconst->pp_is_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2831 if (*op == '.') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2832 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2833 if (may_generate_2STRING(-2, FALSE, cctx) == FAIL |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2834 || may_generate_2STRING(-1, FALSE, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2835 return FAIL; |
28598
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28287
diff
changeset
|
2836 if (generate_CONCAT(cctx, 2) == FAIL) |
d550054e1328
patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28287
diff
changeset
|
2837 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2838 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2839 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2840 generate_two_op(cctx, op); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2841 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2842 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2843 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2844 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2845 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2846 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2847 /* |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2848 * expr6a >> expr6b |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2849 * expr6a << expr6b |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2850 * |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2851 * Produces instructions: |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2852 * OPNR bitwise left or right shift |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2853 */ |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2854 static int |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2855 compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2856 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2857 exprtype_T type = EXPR_UNKNOWN; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2858 char_u *p; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2859 char_u *next; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2860 int len = 2; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2861 int ppconst_used = ppconst->pp_used; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2862 isn_T *isn; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2863 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2864 // get the first variable |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2865 if (compile_expr6(arg, cctx, ppconst) == FAIL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2866 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2867 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2868 /* |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2869 * Repeat computing, until no "+", "-" or ".." is following. |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2870 */ |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2871 for (;;) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2872 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2873 type = EXPR_UNKNOWN; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2874 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2875 p = may_peek_next_line(cctx, *arg, &next); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2876 if (p[0] == '<' && p[1] == '<') |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2877 type = EXPR_LSHIFT; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2878 else if (p[0] == '>' && p[1] == '>') |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2879 type = EXPR_RSHIFT; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2880 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2881 if (type == EXPR_UNKNOWN) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2882 return OK; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2883 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2884 // Handle a bitwise left or right shift operator |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2885 if (ppconst->pp_used == ppconst_used + 1) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2886 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
2887 if (ppconst->pp_tv[ppconst->pp_used - 1].v_type != VAR_NUMBER) |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2888 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2889 // left operand should be a number |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2890 emsg(_(e_bitshift_ops_must_be_number)); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2891 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2892 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2893 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2894 else |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2895 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2896 type_T *t = get_type_on_stack(cctx, 0); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2897 |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
2898 if (need_type(t, &t_number, FALSE, 0, 0, cctx, FALSE, FALSE) == FAIL) |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2899 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2900 emsg(_(e_bitshift_ops_must_be_number)); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2901 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2902 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2903 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2904 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2905 if (next != NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2906 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2907 *arg = next_line_from_context(cctx, TRUE); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2908 p = skipwhite(*arg); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2909 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2910 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2911 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[len])) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2912 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2913 error_white_both(p, len); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2914 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2915 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2916 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2917 // get the second variable |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2918 if (may_get_next_line_error(p + len, arg, cctx) == FAIL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2919 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2920 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2921 if (compile_expr6(arg, cctx, ppconst) == FAIL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2922 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2923 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2924 if (ppconst->pp_used == ppconst_used + 2) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2925 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
2926 typval_T *tv1 = &ppconst->pp_tv[ppconst->pp_used - 2]; |
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
2927 typval_T *tv2 = &ppconst->pp_tv[ppconst->pp_used - 1]; |
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
2928 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2929 // Both sides are a constant, compute the result now. |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2930 if (tv2->v_type != VAR_NUMBER || tv2->vval.v_number < 0) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2931 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2932 // right operand should be a positive number |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2933 if (tv2->v_type != VAR_NUMBER) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2934 emsg(_(e_bitshift_ops_must_be_number)); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2935 else |
30986
360f286b5869
patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents:
30930
diff
changeset
|
2936 emsg(_(e_bitshift_ops_must_be_positive)); |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2937 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2938 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2939 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2940 if (tv2->vval.v_number > MAX_LSHIFT_BITS) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2941 tv1->vval.v_number = 0; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2942 else if (type == EXPR_LSHIFT) |
28968
3043a3e2ef95
patch 8.2.5006: asan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
28966
diff
changeset
|
2943 tv1->vval.v_number = |
3043a3e2ef95
patch 8.2.5006: asan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
28966
diff
changeset
|
2944 (uvarnumber_T)tv1->vval.v_number << tv2->vval.v_number; |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2945 else |
28964
8973f2f00872
patch 8.2.5004: right shift on negative number does not work as documented
Bram Moolenaar <Bram@vim.org>
parents:
28962
diff
changeset
|
2946 tv1->vval.v_number = |
8973f2f00872
patch 8.2.5004: right shift on negative number does not work as documented
Bram Moolenaar <Bram@vim.org>
parents:
28962
diff
changeset
|
2947 (uvarnumber_T)tv1->vval.v_number >> tv2->vval.v_number; |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2948 clear_tv(tv2); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2949 --ppconst->pp_used; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2950 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2951 else |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2952 { |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
2953 if (need_type(get_type_on_stack(cctx, 0), &t_number, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
2954 0, 0, cctx, FALSE, FALSE) == FAIL) |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2955 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2956 emsg(_(e_bitshift_ops_must_be_number)); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2957 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2958 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2959 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2960 generate_ppconst(cctx, ppconst); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2961 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2962 isn = generate_instr_drop(cctx, ISN_OPNR, 1); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2963 if (isn == NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2964 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2965 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2966 if (isn != NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2967 isn->isn_arg.op.op_type = type; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2968 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2969 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2970 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2971 return OK; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2972 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2973 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2974 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2975 * expr5a == expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2976 * expr5a =~ expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2977 * expr5a != expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2978 * expr5a !~ expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2979 * expr5a > expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2980 * expr5a >= expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2981 * expr5a < expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2982 * expr5a <= expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2983 * expr5a is expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2984 * expr5a isnot expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2986 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2987 * EVAL expr5a Push result of "expr5a" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2988 * EVAL expr5b Push result of "expr5b" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2989 * COMPARE one of the compare instructions |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2990 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2991 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2992 compile_expr4(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2993 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2994 exprtype_T type = EXPR_UNKNOWN; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2995 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2996 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2997 int len = 2; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2998 int type_is = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2999 int ppconst_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3000 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3001 // get the first variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3002 if (compile_expr5(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3003 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3004 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3005 p = may_peek_next_line(cctx, *arg, &next); |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3006 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3007 type = get_compare_type(p, &len, &type_is); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3008 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3009 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3010 * If there is a comparative operator, use it. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3011 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3012 if (type != EXPR_UNKNOWN) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3013 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3014 int ic = FALSE; // Default: do not ignore case |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3015 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3016 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3017 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3018 *arg = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3019 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3020 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3021 if (type_is && (p[len] == '?' || p[len] == '#')) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3022 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3023 semsg(_(e_invalid_expression_str), *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3024 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3025 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3026 // extra question mark appended: ignore case |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3027 if (p[len] == '?') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3028 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3029 ic = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3030 ++len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3031 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3032 // extra '#' appended: match case (ignored) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3033 else if (p[len] == '#') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3034 ++len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3035 // nothing appended: match case |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3036 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3037 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[len])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3038 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3039 error_white_both(p, len); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3040 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3041 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3042 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3043 // get the second variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3044 if (may_get_next_line_error(p + len, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3045 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3046 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3047 if (compile_expr5(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3048 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3049 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3050 if (ppconst->pp_used == ppconst_used + 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3051 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
3052 typval_T *tv1 = &ppconst->pp_tv[ppconst->pp_used - 2]; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3053 typval_T *tv2 = &ppconst->pp_tv[ppconst->pp_used - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3054 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3055 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3056 // Both sides are a constant, compute the result now. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3057 // First check for a valid combination of types, this is more |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3058 // strict than typval_compare(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3059 if (check_compare_types(type, tv1, tv2) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3060 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3061 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3062 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3063 ret = typval_compare(tv1, tv2, type, ic); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3064 tv1->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3065 tv1->vval.v_number = tv1->vval.v_number |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3066 ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3067 clear_tv(tv2); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3068 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3069 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3070 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3071 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3072 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3073 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3074 return generate_COMPARE(cctx, type, ic); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3075 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3076 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3077 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3078 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3079 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3080 static int compile_expr3(char_u **arg, cctx_T *cctx, ppconst_T *ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3081 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3082 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3083 * Compile || or &&. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3084 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3085 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3086 compile_and_or( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3087 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3088 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3089 char *op, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3090 ppconst_T *ppconst, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3091 int ppconst_used UNUSED) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3092 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3093 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3094 char_u *p = may_peek_next_line(cctx, *arg, &next); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3095 int opchar = *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3096 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3097 if (p[0] == opchar && p[1] == opchar) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3098 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3099 garray_T *instr = &cctx->ctx_instr; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3100 garray_T end_ga; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3101 int save_skip = cctx->ctx_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3102 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3103 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3104 * Repeat until there is no following "||" or "&&" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3105 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3106 ga_init2(&end_ga, sizeof(int), 10); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3107 while (p[0] == opchar && p[1] == opchar) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3108 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3109 long start_lnum = SOURCING_LNUM; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3110 long save_sourcing_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3111 int start_ctx_lnum = cctx->ctx_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3112 int save_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3113 int const_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3114 int status; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3115 jumpwhen_T jump_when = opchar == '|' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3116 ? JUMP_IF_COND_TRUE : JUMP_IF_COND_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3117 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3118 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3119 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3120 *arg = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3121 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3122 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3123 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3124 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3125 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3126 semsg(_(e_white_space_required_before_and_after_str_at_str), |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3127 op, p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3128 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3129 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3130 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3131 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3132 save_sourcing_lnum = SOURCING_LNUM; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3133 SOURCING_LNUM = start_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 save_lnum = cctx->ctx_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3135 cctx->ctx_lnum = start_ctx_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3136 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3137 status = check_ppconst_bool(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3138 if (status != FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3139 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3140 // Use the last ppconst if possible. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3141 if (ppconst->pp_used > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3142 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3143 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3144 int is_true = tv2bool(tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3145 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3146 if ((is_true && opchar == '|') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3147 || (!is_true && opchar == '&')) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3148 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3149 // For "false && expr" and "true || expr" the "expr" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3150 // does not need to be evaluated. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3151 cctx->ctx_skip = SKIP_YES; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3152 clear_tv(tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3153 tv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3154 tv->vval.v_number = is_true ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3155 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3156 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3157 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3158 // For "true && expr" and "false || expr" only "expr" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3159 // needs to be evaluated. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3160 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3161 jump_when = JUMP_NEVER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3162 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3163 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3164 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3165 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3166 // Every part must evaluate to a bool. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3167 status = bool_on_stack(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3168 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3169 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3170 if (status != FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3171 status = ga_grow(&end_ga, 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3172 cctx->ctx_lnum = save_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3173 if (status == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3174 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3175 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3176 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3177 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3178 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3179 if (jump_when != JUMP_NEVER) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3180 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3181 if (cctx->ctx_skip != SKIP_YES) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3182 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3183 *(((int *)end_ga.ga_data) + end_ga.ga_len) = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3184 ++end_ga.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3185 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3186 generate_JUMP(cctx, jump_when, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3187 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3188 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3189 // eval the next expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3190 SOURCING_LNUM = save_sourcing_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3191 if (may_get_next_line_error(p + 2, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3192 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3193 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3194 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3195 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3196 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3197 const_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3198 if ((opchar == '|' ? compile_expr3(arg, cctx, ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3199 : compile_expr4(arg, cctx, ppconst)) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3200 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3201 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3202 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3203 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3204 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3205 // "0 || 1" results in true, "1 && 0" results in false. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3206 if (ppconst->pp_used == const_used + 1) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3207 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3208 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3209 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3210 if (tv->v_type == VAR_NUMBER |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3211 && (tv->vval.v_number == 1 || tv->vval.v_number == 0)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3212 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3213 tv->vval.v_number = tv->vval.v_number == 1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3214 ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3215 tv->v_type = VAR_BOOL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3216 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3217 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3218 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3219 p = may_peek_next_line(cctx, *arg, &next); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3220 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3221 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3222 if (check_ppconst_bool(ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3223 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3224 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3225 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3226 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3227 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3228 if (cctx->ctx_skip != SKIP_YES && ppconst->pp_used == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3229 // Every part must evaluate to a bool. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3230 if (bool_on_stack(cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3231 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3232 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3233 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3234 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3235 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3236 if (end_ga.ga_len > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3237 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3238 // Fill in the end label in all jumps. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3239 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3240 while (end_ga.ga_len > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3241 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3242 isn_T *isn; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3243 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3244 --end_ga.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3245 isn = ((isn_T *)instr->ga_data) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3246 + *(((int *)end_ga.ga_data) + end_ga.ga_len); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3247 isn->isn_arg.jump.jump_where = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3248 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3249 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3250 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3251 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3252 cctx->ctx_skip = save_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3253 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3254 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3255 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3256 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3257 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3258 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3259 * expr4a && expr4a && expr4a logical AND |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3260 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3261 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3262 * EVAL expr4a Push result of "expr4a" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3263 * COND2BOOL convert to bool if needed |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3264 * JUMP_IF_COND_FALSE end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3265 * EVAL expr4b Push result of "expr4b" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3266 * JUMP_IF_COND_FALSE end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3267 * EVAL expr4c Push result of "expr4c" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3268 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3269 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3270 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3271 compile_expr3(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3272 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3273 int ppconst_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3274 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3275 // get the first variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3276 if (compile_expr4(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3277 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3278 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3279 // || and && work almost the same |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3280 return compile_and_or(arg, cctx, "&&", ppconst, ppconst_used); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3281 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3282 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3283 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3284 * expr3a || expr3b || expr3c logical OR |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3285 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3286 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3287 * EVAL expr3a Push result of "expr3a" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3288 * COND2BOOL convert to bool if needed |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3289 * JUMP_IF_COND_TRUE end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3290 * EVAL expr3b Push result of "expr3b" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3291 * JUMP_IF_COND_TRUE end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3292 * EVAL expr3c Push result of "expr3c" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3293 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3294 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3295 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3296 compile_expr2(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3297 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3298 int ppconst_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3299 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3300 // eval the first expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3301 if (compile_expr3(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3302 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3303 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3304 // || and && work almost the same |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3305 return compile_and_or(arg, cctx, "||", ppconst, ppconst_used); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3306 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3307 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3308 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3309 * Toplevel expression: expr2 ? expr1a : expr1b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3310 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3311 * EVAL expr2 Push result of "expr2" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3312 * JUMP_IF_FALSE alt jump if false |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3313 * EVAL expr1a |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3314 * JUMP_ALWAYS end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3315 * alt: EVAL expr1b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3316 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3317 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3318 * Toplevel expression: expr2 ?? expr1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3319 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3320 * EVAL expr2 Push result of "expr2" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3321 * JUMP_AND_KEEP_IF_TRUE end jump if true |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3322 * EVAL expr1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3323 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3324 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3325 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3326 compile_expr1(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3327 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3328 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3329 int ppconst_used = ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3330 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3331 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3332 // Ignore all kinds of errors when not producing code. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3333 if (cctx->ctx_skip == SKIP_YES) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3334 { |
27539
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27505
diff
changeset
|
3335 int prev_did_emsg = did_emsg; |
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27505
diff
changeset
|
3336 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3337 skip_expr_cctx(arg, cctx); |
27539
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27505
diff
changeset
|
3338 return did_emsg == prev_did_emsg ? OK : FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3339 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3340 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3341 // Evaluate the first expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3342 if (compile_expr2(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3343 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3344 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3345 p = may_peek_next_line(cctx, *arg, &next); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3346 if (*p == '?') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3347 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3348 int op_falsy = p[1] == '?'; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3349 garray_T *instr = &cctx->ctx_instr; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3350 garray_T *stack = &cctx->ctx_type_stack; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3351 int alt_idx = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3352 int end_idx = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3353 isn_T *isn; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3354 type_T *type1 = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3355 int has_const_expr = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3356 int const_value = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3357 int save_skip = cctx->ctx_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3358 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3359 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3360 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3361 *arg = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3362 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3363 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3364 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3365 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3366 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3367 semsg(_(e_white_space_required_before_and_after_str_at_str), |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3368 op_falsy ? "??" : "?", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3369 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3370 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3372 if (ppconst->pp_used == ppconst_used + 1) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3373 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3374 // the condition is a constant, we know whether the ? or the : |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3375 // expression is to be evaluated. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3376 has_const_expr = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3377 if (op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3378 const_value = tv2bool(&ppconst->pp_tv[ppconst_used]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3379 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3380 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3381 int error = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3382 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3383 const_value = tv_get_bool_chk(&ppconst->pp_tv[ppconst_used], |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3384 &error); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3385 if (error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3386 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3387 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3388 cctx->ctx_skip = save_skip == SKIP_YES || |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3389 (op_falsy ? const_value : !const_value) ? SKIP_YES : SKIP_NOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3390 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3391 if (op_falsy && cctx->ctx_skip == SKIP_YES) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3392 // "left ?? right" and "left" is truthy: produce "left" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3393 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3394 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3395 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3396 clear_tv(&ppconst->pp_tv[ppconst_used]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3397 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3398 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3399 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3400 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3401 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3402 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3403 if (op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3404 end_idx = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3405 generate_JUMP(cctx, op_falsy |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3406 ? JUMP_AND_KEEP_IF_TRUE : JUMP_IF_FALSE, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3407 if (op_falsy) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
3408 type1 = get_type_on_stack(cctx, -1); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3409 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3410 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3411 // evaluate the second expression; any type is accepted |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3412 if (may_get_next_line_error(p + 1 + op_falsy, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3413 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3414 if (compile_expr1(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3415 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3416 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3417 if (!has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3418 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3419 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3420 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3421 if (!op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3422 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3423 // remember the type and drop it |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
3424 type1 = get_type_on_stack(cctx, 0); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3425 --stack->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3426 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3427 end_idx = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3428 generate_JUMP(cctx, JUMP_ALWAYS, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3429 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3430 // jump here from JUMP_IF_FALSE |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3431 isn = ((isn_T *)instr->ga_data) + alt_idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3432 isn->isn_arg.jump.jump_where = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3433 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3434 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3435 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3436 if (!op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3437 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3438 // Check for the ":". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3439 p = may_peek_next_line(cctx, *arg, &next); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3440 if (*p != ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3441 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3442 emsg(_(e_missing_colon_after_questionmark)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3443 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3444 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3445 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3446 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3447 *arg = next_line_from_context(cctx, TRUE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3448 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3449 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3450 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3451 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3452 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3453 semsg(_(e_white_space_required_before_and_after_str_at_str), |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3454 ":", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3455 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3456 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3457 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3458 // evaluate the third expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3459 if (has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3460 cctx->ctx_skip = save_skip == SKIP_YES || const_value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3461 ? SKIP_YES : SKIP_NOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3462 if (may_get_next_line_error(p + 1, arg, cctx) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3463 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3464 if (compile_expr1(arg, cctx, ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3465 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3466 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3467 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3468 if (!has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3469 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3470 type_T **typep; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3471 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3472 generate_ppconst(cctx, ppconst); |
26680
1b288eb2fcdc
patch 8.2.3869: Vim9: type checking for "any" is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26674
diff
changeset
|
3473 ppconst->pp_is_const = FALSE; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3474 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3475 // If the types differ, the result has a more generic type. |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
3476 typep = &((((type2_T *)stack->ga_data) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
3477 + stack->ga_len - 1)->type_curr); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3478 common_type(type1, *typep, typep, cctx->ctx_type_list); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3479 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3480 // jump here from JUMP_ALWAYS or JUMP_AND_KEEP_IF_TRUE |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3481 isn = ((isn_T *)instr->ga_data) + end_idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3482 isn->isn_arg.jump.jump_where = instr->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3483 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3484 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3485 cctx->ctx_skip = save_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3486 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3487 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3488 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3489 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3490 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3491 * Toplevel expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3492 * Sets "is_const" (if not NULL) to indicate the value is a constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3493 * Returns OK or FAIL. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3494 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3495 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3496 compile_expr0_ext(char_u **arg, cctx_T *cctx, int *is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3497 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3498 ppconst_T ppconst; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3499 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3500 CLEAR_FIELD(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3501 if (compile_expr1(arg, cctx, &ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3502 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3503 clear_ppconst(&ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3504 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3505 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3506 if (is_const != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3507 *is_const = ppconst.pp_used > 0 || ppconst.pp_is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3508 if (generate_ppconst(cctx, &ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3509 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3510 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3511 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3512 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3513 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3514 * Toplevel expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3515 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3516 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3517 compile_expr0(char_u **arg, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3518 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3519 return compile_expr0_ext(arg, cctx, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3520 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3521 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3522 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3523 #endif // defined(FEAT_EVAL) |