Mercurial > vim
annotate src/vim9expr.c @ 33738:2172872dfbcd v9.0.2096
patch 9.0.2096: Vim9: confusing usage of private
Commit: https://github.com/vim/vim/commit/03042a2753e3e6ac971045a8ce256d709214710e
Author: Ernie Rael <errael@raelity.com>
Date: Sat Nov 11 08:53:32 2023 +0100
patch 9.0.2096: Vim9: confusing usage of private
Problem: Vim9: confusing usage of private
Solution: clarify and use protected keyword instead
[vim9class] document `_` as protected instead of private
fixes #13504
closes: #13520
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 11 Nov 2023 09:00:06 +0100 |
parents | f126ffc85f7c |
children | 84b93d95a952 |
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: |
33678
7d9d2404a3d4
patch 9.0.2076: Vim9: No support for type aliases
Christian Brabandt <cb@256bit.org>
parents:
33611
diff
changeset
|
241 case VAR_TYPEALIAS: |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 case VAR_UNKNOWN: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 case VAR_ANY: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 case VAR_VOID: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 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
|
246 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 default: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 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
|
249 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 /* |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
256 * Returns TRUE if the current function is inside the class "cl" or one of the |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
257 * parent classes. |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
258 */ |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
259 static int |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
260 inside_class_hierarchy(cctx_T *cctx_arg, class_T *cl) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
261 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
262 for (cctx_T *cctx = cctx_arg; cctx != NULL; cctx = cctx->ctx_outer) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
263 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
264 if (cctx->ctx_ufunc != NULL && cctx->ctx_ufunc->uf_class != NULL) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
265 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
266 class_T *clp = cctx->ctx_ufunc->uf_class; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
267 while (clp != NULL) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
268 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
269 if (clp == cl) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
270 return TRUE; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
271 clp = clp->class_extends; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
272 } |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
273 } |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
274 } |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
275 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
276 return FALSE; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
277 } |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
278 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
279 /* |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
280 * 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
|
281 */ |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
282 static int |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
283 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
|
284 { |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
285 int m_idx; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
286 |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
287 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
|
288 { |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
289 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
|
290 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
291 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
292 |
32005
ef644af2c330
patch 9.0.1334: using tt_member for the class leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
31982
diff
changeset
|
293 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
|
294 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
|
295 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
|
296 { |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
297 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
|
298 { |
33343
41b50abddeea
patch 9.0.1935: Vim9: not consistent error messages
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
299 emsg(_(e_using_super_not_in_class_method)); |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
300 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
|
301 } |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
302 is_super = TRUE; |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
303 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
|
304 // 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
|
305 --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
|
306 } |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
307 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
|
308 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
309 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
|
310 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
|
311 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
312 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
|
313 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
|
314 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
315 // 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
|
316 // 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
|
317 --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
|
318 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
|
319 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
320 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
321 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
322 |
32088
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
323 if (cl == NULL) |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
324 { |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
325 // TODO: this should not give an error but be handled at runtime |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
326 emsg(_(e_incomplete_type)); |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
327 return FAIL; |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
328 } |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
329 |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
330 ++*arg; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
331 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
|
332 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
|
333 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
|
334 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
335 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
|
336 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
337 if (*name_end == '(') |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
338 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
343 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
|
344 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 } |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
349 else |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
350 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
351 // 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
|
352 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
|
353 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
|
354 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
|
355 } |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
356 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
357 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
|
358 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
|
359 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
|
360 { |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
361 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
|
362 // 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
|
363 // 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
|
364 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
|
365 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
|
366 { |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
367 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
|
368 break; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
369 } |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
370 } |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
371 ocmember_T *ocm = NULL; |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
372 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
|
373 { |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
374 // could be a funcref in a member variable |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
375 ocm = member_lookup(cl, type->tt_type, name, len, &m_idx); |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
376 if (ocm == NULL || ocm->ocm_type->tt_type != VAR_FUNC) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
377 { |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
378 method_not_found_msg(cl, type->tt_type, name, len); |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
379 return FAIL; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
380 } |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
381 if (type->tt_type == VAR_CLASS) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
382 { |
33611
de690130ba43
patch 9.0.2049: Vim9: not recognizing qualified class vars for infix ops
Christian Brabandt <cb@256bit.org>
parents:
33587
diff
changeset
|
383 // Remove the class type from the stack |
de690130ba43
patch 9.0.2049: Vim9: not recognizing qualified class vars for infix ops
Christian Brabandt <cb@256bit.org>
parents:
33587
diff
changeset
|
384 --cctx->ctx_type_stack.ga_len; |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
385 if (generate_CLASSMEMBER(cctx, TRUE, cl, m_idx) == FAIL) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
386 return FAIL; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
387 } |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
388 else |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
389 { |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
390 if (generate_GET_OBJ_MEMBER(cctx, m_idx, ocm->ocm_type) == |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
391 FAIL) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
392 return FAIL; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
393 } |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
394 } |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
395 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
396 // A private object method can be used only inside the class where it |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
397 // is defined or in one of the child classes. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
398 // A private class method can be used only in the class where it is |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
399 // defined. |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
400 if (ocm == NULL && *ufunc->uf_name == '_' && |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
401 ((type->tt_type == VAR_OBJECT |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
402 && !inside_class_hierarchy(cctx, cl)) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
403 || (type->tt_type == VAR_CLASS |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
404 && cctx->ctx_ufunc->uf_class != cl))) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
405 { |
33738
2172872dfbcd
patch 9.0.2096: Vim9: confusing usage of private
Christian Brabandt <cb@256bit.org>
parents:
33682
diff
changeset
|
406 semsg(_(e_cannot_access_protected_method_str), name); |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
407 return FAIL; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
408 } |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
409 |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
410 // 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
|
411 // 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
|
412 // 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
|
413 *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
|
414 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
|
415 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
|
416 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
|
417 |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
418 if (ocm != NULL) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
419 return generate_PCALL(cctx, argcount, name, ocm->ocm_type, TRUE); |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
420 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
|
421 && (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))) |
33326
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
422 return generate_CALL(cctx, ufunc, cl, fi, argcount); |
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
423 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
|
424 } |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
425 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
426 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
|
427 { |
33246
877dddec681f
patch 9.0.1895: Vim9: finding object method/member is inefficient
Christian Brabandt <cb@256bit.org>
parents:
33233
diff
changeset
|
428 ocmember_T *m = object_member_lookup(cl, name, len, &m_idx); |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
429 if (m_idx >= 0) |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
430 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
431 if (*name == '_' && !inside_class(cctx, cl)) |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
432 { |
33738
2172872dfbcd
patch 9.0.2096: Vim9: confusing usage of private
Christian Brabandt <cb@256bit.org>
parents:
33682
diff
changeset
|
433 emsg_var_cl_define(e_cannot_access_protected_variable_str, |
33498
bff8ac203a22
patch 9.0.1999: Vim9: some error messages can be improved
Christian Brabandt <cb@256bit.org>
parents:
33456
diff
changeset
|
434 m->ocm_name, 0, cl); |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
435 return FAIL; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
436 } |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
437 |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
438 *arg = name_end; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
439 if (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED)) |
33387
577ef266309d
patch 9.0.1952: Vim9: unused static field
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
440 return generate_GET_ITF_MEMBER(cctx, cl, m_idx, m->ocm_type); |
577ef266309d
patch 9.0.1952: Vim9: unused static field
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
441 return generate_GET_OBJ_MEMBER(cctx, m_idx, m->ocm_type); |
33173
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
442 } |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
443 |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
444 // Could be an object method reference: "obj.Func". |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
445 m_idx = object_method_idx(cl, name, len); |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
446 if (m_idx >= 0) |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
447 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
448 ufunc_T *fp = cl->class_obj_methods[m_idx]; |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
449 // Private methods are not accessible outside the class |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
450 if (*name == '_' && !inside_class(cctx, cl)) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
451 { |
33738
2172872dfbcd
patch 9.0.2096: Vim9: confusing usage of private
Christian Brabandt <cb@256bit.org>
parents:
33682
diff
changeset
|
452 semsg(_(e_cannot_access_protected_method_str), fp->uf_name); |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
453 return FAIL; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
454 } |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
455 *arg = name_end; |
33587
c470d4fd5eba
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Christian Brabandt <cb@256bit.org>
parents:
33540
diff
changeset
|
456 // Remove the object type from the stack |
c470d4fd5eba
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Christian Brabandt <cb@256bit.org>
parents:
33540
diff
changeset
|
457 --cctx->ctx_type_stack.ga_len; |
c470d4fd5eba
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Christian Brabandt <cb@256bit.org>
parents:
33540
diff
changeset
|
458 return generate_FUNCREF(cctx, fp, cl, TRUE, m_idx, NULL); |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
459 } |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
460 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
461 member_not_found_msg(cl, VAR_OBJECT, name, len); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
462 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
463 else |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
464 { |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
465 // 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
|
466 int idx; |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
467 ocmember_T *m = class_member_lookup(cl, name, len, &idx); |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
468 if (m != NULL) |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
469 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
470 // Note: type->tt_type = VAR_CLASS |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
471 // A private class variable can be accessed only in the class where |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
472 // it is defined. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
473 if (*name == '_' && cctx->ctx_ufunc->uf_class != cl) |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
474 { |
33738
2172872dfbcd
patch 9.0.2096: Vim9: confusing usage of private
Christian Brabandt <cb@256bit.org>
parents:
33682
diff
changeset
|
475 emsg_var_cl_define(e_cannot_access_protected_variable_str, |
33498
bff8ac203a22
patch 9.0.1999: Vim9: some error messages can be improved
Christian Brabandt <cb@256bit.org>
parents:
33456
diff
changeset
|
476 m->ocm_name, 0, cl); |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
477 return FAIL; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
478 } |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
479 |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
480 *arg = name_end; |
33611
de690130ba43
patch 9.0.2049: Vim9: not recognizing qualified class vars for infix ops
Christian Brabandt <cb@256bit.org>
parents:
33587
diff
changeset
|
481 // Remove the class type from the stack |
de690130ba43
patch 9.0.2049: Vim9: not recognizing qualified class vars for infix ops
Christian Brabandt <cb@256bit.org>
parents:
33587
diff
changeset
|
482 --cctx->ctx_type_stack.ga_len; |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
483 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
|
484 } |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
485 |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
486 // Could be a class method reference: "class.Func". |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
487 m_idx = class_method_idx(cl, name, len); |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
488 if (m_idx >= 0) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
489 { |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
490 ufunc_T *fp = cl->class_class_functions[m_idx]; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
491 // Private methods are not accessible outside the class |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
492 if (*name == '_' && !inside_class(cctx, cl)) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
493 { |
33738
2172872dfbcd
patch 9.0.2096: Vim9: confusing usage of private
Christian Brabandt <cb@256bit.org>
parents:
33682
diff
changeset
|
494 semsg(_(e_cannot_access_protected_method_str), fp->uf_name); |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
495 return FAIL; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
496 } |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
497 *arg = name_end; |
33587
c470d4fd5eba
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Christian Brabandt <cb@256bit.org>
parents:
33540
diff
changeset
|
498 // Remove the class type from the stack |
c470d4fd5eba
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Christian Brabandt <cb@256bit.org>
parents:
33540
diff
changeset
|
499 --cctx->ctx_type_stack.ga_len; |
c470d4fd5eba
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Christian Brabandt <cb@256bit.org>
parents:
33540
diff
changeset
|
500 return generate_FUNCREF(cctx, fp, cl, FALSE, m_idx, NULL); |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
501 } |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
502 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
503 member_not_found_msg(cl, VAR_CLASS, name, len); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
504 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
505 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
506 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
507 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
508 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
509 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 * 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
|
511 * leading "s:". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 * Also finds imported variables. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 compile_load_scriptvar( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 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
|
518 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
|
519 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
|
520 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 scriptitem_T *si; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 imported_T *import; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 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
|
526 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 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
|
528 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
|
529 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 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
|
532 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 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
|
534 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
|
535 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
538 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
|
539 if (import != NULL) |
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 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
|
542 char_u *exp_name; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
543 int cc; |
28271
c84f4e34ba16
patch 8.2.4661: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
544 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
|
545 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
|
546 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
|
547 int res = OK; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
549 // 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
|
550 if (*p != '.') |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
551 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
552 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
|
553 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
554 } |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
555 ++p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
556 if (VIM_ISWHITE(*p)) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
557 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
558 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
|
559 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
560 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
562 // isolate one name |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
563 exp_name = p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
564 while (eval_isnamec(*p)) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
565 ++p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
566 cc = *p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
567 *p = NUL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
568 |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
569 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
|
570 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
|
571 // "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
|
572 // "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
|
573 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
|
574 |
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
|
575 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
|
576 { |
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
|
577 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
|
578 && 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
|
579 { |
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
|
580 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
|
581 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
|
582 |
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
|
583 // 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
|
584 // 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
|
585 // 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 } |
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
|
593 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
|
594 && 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
|
595 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
596 // 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
|
597 // 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
|
598 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
|
599 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
600 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
|
601 |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
602 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
|
603 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
|
604 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
605 else |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
606 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
|
607 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
|
608 done = TRUE; |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
609 } |
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
|
610 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
|
611 { |
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
|
612 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
|
613 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
|
614 } |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
615 } |
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
|
616 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
617 *p = cc; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
618 *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
|
619 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
|
620 return res; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
622 if (idx < 0) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
623 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
624 if (ufunc != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 { |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
626 // 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
|
627 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
|
628 return OK; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 } |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
630 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
631 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
633 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
|
634 import->imp_sid, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
635 idx, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
636 type); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
640 // 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
|
641 // 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
|
642 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
|
643 &t_any); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 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
|
647 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
|
648 { |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
649 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
|
650 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
|
651 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
652 // 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
|
653 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
|
654 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 // 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
|
657 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
|
658 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
|
659 && 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
|
660 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
|
661 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
|
662 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 |
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 * 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
|
666 * "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
|
667 * "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
|
668 * 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
|
669 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 compile_load( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 char_u *end_arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 int is_expr, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 int error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 type_T *type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 char_u *name = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 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
|
681 int res = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 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
|
683 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 if (*(*arg + 1) == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 if (end <= *arg + 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 isntype_T isn_type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 // load dictionary of namespace |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 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
|
694 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
|
695 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
|
696 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
|
697 default: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 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
|
699 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 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
|
702 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 res = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 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
|
708 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 // load namespaced variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 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
|
711 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 { |
28992
0e9642706a59
patch 8.2.5018: Vim9: some code is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
716 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
|
717 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
|
718 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
|
719 { |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
720 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
|
721 *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
|
722 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
|
723 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
|
724 } |
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
|
725 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
|
726 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
|
727 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 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
|
729 NULL, &end); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 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
|
732 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 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
|
734 && 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
|
735 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
|
736 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 isn_type = ISN_LOADG; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 isn_type = ISN_LOADAUTO; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 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
|
744 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 goto theend; |
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 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
|
756 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 // 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
|
758 // 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
|
759 // 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
|
760 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
|
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 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
|
767 int idx; |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
768 int method_idx; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 int gen_load = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 int gen_load_outer = 0; |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
771 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
|
772 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
|
773 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 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
|
775 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 |
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
|
778 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
|
779 && 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
|
780 && (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
|
781 { |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
782 // 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
|
783 // 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
|
784 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
|
785 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
|
786 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
|
787 } |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
788 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
|
789 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 script_autoload(name, FALSE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 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
|
792 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 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
|
794 == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 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
|
797 gen_load = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 { |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
801 lvar_T lvar; |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
802 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
|
803 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 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
|
805 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 type = lvar.lv_type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 idx = lvar.lv_idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 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
|
809 { |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 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
|
811 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
|
812 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
|
813 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 gen_load = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 } |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
817 else if (cctx->ctx_ufunc->uf_defclass != NULL && |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
818 (((idx = |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
819 cctx_class_member_idx(cctx, *arg, len, &cl)) >= 0) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
820 || ((method_idx = |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
821 cctx_class_method_idx(cctx, *arg, len, &cl)) >= 0))) |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
822 { |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
823 // Referencing a class variable or method without the class |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
824 // name. A class variable or method can be referenced without |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
825 // the class name only in the class where the function is |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
826 // defined. |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
827 if (cctx->ctx_ufunc->uf_defclass == cl) |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
828 { |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
829 if (idx >= 0) |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
830 res = generate_CLASSMEMBER(cctx, TRUE, cl, idx); |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
831 else |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
832 { |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
833 ufunc_T *fp = cl->class_class_functions[method_idx]; |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
834 res = generate_FUNCREF(cctx, fp, cl, FALSE, method_idx, |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
835 NULL); |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
836 } |
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
837 } |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
838 else |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
839 { |
33343
41b50abddeea
patch 9.0.1935: Vim9: not consistent error messages
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
840 semsg(_(e_class_variable_str_accessible_only_inside_class_str), |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
841 name, cl->class_name); |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
842 res = FAIL; |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
843 } |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
844 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 // "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
|
848 // 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
|
849 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
|
850 || 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
|
851 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
|
852 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 // 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
|
854 // 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
|
855 // 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
|
856 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
|
857 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
|
858 } |
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 if (gen_load) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 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
|
862 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
|
863 { |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
864 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
|
865 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
|
866 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
|
867 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 *arg = end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 theend: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 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
|
874 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
|
875 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 return res; |
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 |
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 * 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
|
881 * "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
|
882 * 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
|
883 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 static int |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
885 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
|
886 { |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
887 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
|
888 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
|
889 int expr_res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 int trailing_error; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 int instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 isn_T *instr = NULL; |
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 // 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
|
895 --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
|
896 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 // 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
|
898 // correct. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 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
|
900 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
|
901 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
|
902 |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
903 // 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
|
904 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
|
905 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
|
906 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 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
|
908 |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
909 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
|
910 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 s = skipwhite(s); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 trailing_error = *s != NUL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 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
|
915 || 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
|
916 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 if (trailing_error) |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
918 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
|
919 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
|
920 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
|
921 ++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
|
922 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 // 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
|
926 // 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
|
927 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
|
928 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
|
929 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
|
930 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 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
|
932 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
|
933 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
|
934 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
|
935 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 * Compile the argument expressions. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 * "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
|
941 */ |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
942 int |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
943 compile_arguments( |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
944 char_u **arg, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
945 cctx_T *cctx, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
946 int *argcount, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
947 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
|
948 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 char_u *p = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 char_u *whitep = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 int must_end = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 int instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 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
|
957 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 if (*p == ')') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 *arg = p + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 if (must_end) |
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 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
|
966 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 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
|
970 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
|
971 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 ++*argcount; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
974 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
|
975 && 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
|
976 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 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
|
978 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 // {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
|
980 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
|
981 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
|
982 } |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
983 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
|
984 && 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
|
985 { |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
986 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
|
987 |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
988 // {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
|
989 // with \= |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
990 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
|
991 && 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
|
992 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
|
993 } |
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 if (*p != ',' && *skipwhite(p) == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 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
|
998 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 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
|
1004 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
|
1005 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 must_end = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 whitep = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 p = skipwhite(p); |
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 failret: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 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
|
1013 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 * 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
|
1018 * "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
|
1019 * "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
|
1020 * Instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 * EVAL arg1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 * EVAL arg2 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 * BCALL / DCALL / UCALL |
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 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 compile_call( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 size_t varlen, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 ppconst_T *ppconst, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 int argcount_init) |
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 char_u *name = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 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
|
1036 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
|
1037 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
|
1038 char_u *tofree = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 ufunc_T *ufunc = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 int res = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
1046 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
|
1047 { |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
1048 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
|
1049 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
|
1050 } |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
1051 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
|
1052 |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
1053 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
|
1054 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
|
1055 { |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
1056 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
|
1057 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
|
1058 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 // 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
|
1061 // 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
|
1062 // 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
|
1063 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
|
1064 && (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
|
1065 || (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
|
1066 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 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
|
1068 typval_T argvars[2]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 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
|
1070 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
|
1071 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 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
|
1073 if (*s == '"') |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1074 (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
|
1075 else if (*s == '\'') |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1076 (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
|
1077 s = skipwhite(s); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 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
|
1079 && ((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
|
1080 || !is_has)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 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
|
1083 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 *arg = s + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 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
|
1086 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
|
1087 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
|
1088 if (is_has) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 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
|
1090 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
|
1091 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
|
1092 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 f_exists(argvars, tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 clear_tv(&argvars[0]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 ++ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 return OK; |
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 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
|
1099 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
|
1100 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 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
|
1102 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 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
|
1107 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 |
31982
9113d903a2c6
patch 9.0.1323: build failure with +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1109 funcerror_T error; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 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
|
1111 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 // 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
|
1113 // differently. |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1114 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
|
1115 || (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
|
1116 || (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
|
1117 || (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
|
1118 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
|
1119 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
|
1120 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
|
1121 else |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1122 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
|
1123 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 *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
|
1125 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
|
1126 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 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
|
1129 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
|
1130 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 // builtin function |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 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
|
1135 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 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
|
1138 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 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
|
1140 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 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
|
1144 { |
33326
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
1145 type_T *type = get_decl_type_on_stack(cctx, 1); |
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
1146 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 // 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
|
1148 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
|
1149 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 // 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
|
1151 res = generate_LISTAPPEND(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 idx = -1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 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
|
1155 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 // 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
|
1157 res = generate_BLOBAPPEND(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 idx = -1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 } |
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 |
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
|
1162 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
|
1163 || (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
|
1164 { |
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
|
1165 // 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
|
1166 // 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
|
1167 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
|
1168 idx = -1; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1169 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1170 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 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
|
1173 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 else |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1175 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
|
1176 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1179 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
|
1180 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 // 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
|
1182 // overrules a function name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 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
|
1184 && 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
|
1185 { |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1186 class_T *cl = NULL; |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1187 int mi = 0; |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1188 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 // 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
|
1190 // 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
|
1191 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
|
1192 if (ufunc != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 { |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1194 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
|
1195 { |
33326
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
1196 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
|
1197 goto theend; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1198 } |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1199 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
|
1200 && 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
|
1201 { |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1202 // 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
|
1203 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
|
1204 goto theend; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1205 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 } |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1207 else if ((mi = cctx_class_method_idx(cctx, name, varlen, &cl)) >= 0) |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1208 { |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1209 // Class method invocation without the class name. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1210 // A class method can be referenced without the class name only in |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1211 // the class where the function is defined. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1212 if (cctx->ctx_ufunc->uf_defclass == cl) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1213 { |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1214 res = generate_CALL(cctx, cl->class_class_functions[mi], NULL, |
33326
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
1215 0, argcount); |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1216 } |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1217 else |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1218 { |
33343
41b50abddeea
patch 9.0.1935: Vim9: not consistent error messages
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
1219 semsg(_(e_class_method_str_accessible_only_inside_class_str), |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1220 name, cl->class_name); |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1221 res = FAIL; |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1222 } |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1223 goto theend; |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1224 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 // 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
|
1228 // 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
|
1229 // 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
|
1230 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
|
1231 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
|
1232 && 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
|
1233 { |
32840
a8561f9b47aa
patch 9.0.1732: vimexpr: shadowing variable
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1234 type_T *s_type = get_type_on_stack(cctx, 0); |
a8561f9b47aa
patch 9.0.1732: vimexpr: shadowing variable
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1235 |
a8561f9b47aa
patch 9.0.1732: vimexpr: shadowing variable
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1236 res = generate_PCALL(cctx, argcount, namebuf, s_type, FALSE); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 // 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
|
1241 if (ufunc != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 { |
33326
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
1243 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
|
1244 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 // 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
|
1248 // 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
|
1249 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
|
1250 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
|
1251 else |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1252 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
|
1253 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 theend: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 vim_free(tofree); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 return res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 // 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
|
1260 #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
|
1261 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 * 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
|
1264 * 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
|
1265 * 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
|
1266 * 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
|
1267 * valid name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 char_u * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 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
|
1271 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 // 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
|
1275 if (!eval_isnamec1(*arg)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 return arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 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
|
1279 // 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
|
1280 // 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
|
1281 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
|
1282 || !use_namespace |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 || 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
|
1284 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 return p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 * 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
|
1290 * 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
|
1291 * 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
|
1292 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 char_u * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 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
|
1295 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 char_u *p = arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 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
|
1300 p = skipdigits(p + 5); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 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
|
1302 if (p == arg && *arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 { |
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 // 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
|
1306 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
|
1307 p = arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 return p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 |
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 * 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
|
1314 * "*arg" points to the '['. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 * 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
|
1316 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 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
|
1319 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 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
|
1321 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
|
1322 int count = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 int is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 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
|
1325 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
|
1326 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 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
|
1330 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26769
diff
changeset
|
1331 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
|
1332 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 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
|
1337 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 if (*p == ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 } |
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
|
1344 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
|
1345 { |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1346 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
|
1347 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
|
1348 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 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
|
1350 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 if (!is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 is_all_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 ++count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 if (*p == ',') |
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 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 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
|
1358 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 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
|
1360 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 } |
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
|
1363 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
|
1364 must_end = TRUE; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 whitep = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 *arg = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 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
|
1371 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
|
1372 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 * 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
|
1376 * "*arg" points to the '('. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 * 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
|
1378 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 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
|
1381 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 ufunc_T *ufunc; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 evalarg_T evalarg; |
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 init_evalarg(&evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 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
|
1389 evalarg.eval_cctx = cctx; |
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 // 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
|
1392 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
|
1393 if (r != OK) |
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 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 return r; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 // "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
|
1400 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
|
1401 ++ufunc->uf_refcount; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 clear_tv(&rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 // 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
|
1405 // 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
|
1406 // compile_return(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 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
|
1408 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
|
1409 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
|
1410 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 // 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
|
1412 // 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
|
1413 // the right context. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 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
|
1415 #ifdef FEAT_PROFILE |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 || 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
|
1417 #endif |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 ) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 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
|
1420 |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1421 // 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
|
1422 // one might be |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1423 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
|
1424 { |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1425 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
|
1426 |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1427 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
|
1428 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
|
1429 } |
632a84e2ce92
patch 8.2.4573: a nested function is compiled for debugging without context
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
1430 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 // 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
|
1432 // "*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
|
1433 // dangling pointer. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 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
|
1435 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 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
|
1437 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
|
1438 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 *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
|
1440 + off; |
30437
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
1441 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
|
1442 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 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
|
1447 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 // 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
|
1449 set_function_type(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 // 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
|
1452 // 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
|
1453 // function is freed. |
33540
86dbcbb94fdb
patch 9.0.2019: Vim9: no support for funcrefs
Christian Brabandt <cb@256bit.org>
parents:
33498
diff
changeset
|
1454 return generate_FUNCREF(cctx, ufunc, NULL, FALSE, 0, NULL); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 } |
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 func_ptr_unref(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 * 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
|
1463 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 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
|
1466 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 typval_T *rettv, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 int types_optional, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 evalarg_T *evalarg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 ufunc_T *ufunc; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 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
|
1474 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 // 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
|
1476 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
|
1477 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
|
1478 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
|
1479 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
|
1480 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
|
1481 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 // "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
|
1483 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
|
1484 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 // 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
|
1486 // 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
|
1487 // compile_return(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 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
|
1489 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
|
1490 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
|
1491 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 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
|
1493 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 // 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
|
1495 set_function_type(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 * 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
|
1504 * "*arg" points to the '{'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 * 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
|
1506 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 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
|
1509 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 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
|
1511 int count = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 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
|
1513 dictitem_T *item; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 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
|
1515 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 int is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 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
|
1518 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 if (d == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 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
|
1522 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 char_u *key = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 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
|
1528 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 } |
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 if (**arg == '}') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 if (**arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 isn_T *isn; |
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 // {[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
|
1541 *arg = skipwhite(*arg + 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 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
|
1543 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 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
|
1545 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
|
1546 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 char buf[NUMBUFLEN]; |
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 // 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
|
1550 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
|
1551 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
|
1552 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
|
1553 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 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
|
1555 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
|
1556 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
|
1557 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 if (**arg != ']') |
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 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
|
1562 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 else |
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 // {"name": value}, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 // {'name': value}, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 // {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
|
1571 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
|
1572 if (key == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 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
|
1575 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 // 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
|
1579 if (key != NULL) |
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 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
|
1582 if (item != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1584 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
|
1585 goto failret; |
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 item = dictitem_alloc(key); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 if (item != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 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
|
1591 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
|
1592 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
|
1593 dictitem_free(item); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1597 if (**arg != ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 if (*skipwhite(*arg) == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 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
|
1601 else |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1602 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
|
1603 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 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
|
1607 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1608 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
|
1609 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 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
|
1613 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 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
|
1619 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 if (!is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 is_all_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 ++count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 whitep = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 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
|
1626 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1628 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 if (**arg == '}') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 if (**arg != ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1634 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
|
1635 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 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
|
1638 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 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
|
1640 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 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
|
1644 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 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
|
1646 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 *arg = skipwhite(whitep); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 *arg = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 // 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
|
1654 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 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
|
1656 *arg += STRLEN(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 dict_unref(d); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 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
|
1660 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
|
1661 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 failret: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 if (*arg == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1665 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
|
1666 *arg = (char_u *)""; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 dict_unref(d); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 * Compile "&option". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 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
|
1677 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 char_u *start = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 int ret; |
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 // 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
|
1683 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
|
1684 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
|
1685 if (ret == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 // 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
|
1688 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
|
1689 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
|
1690 : 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
|
1691 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 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
|
1693 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 clear_tv(&rettv); |
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 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1701 * Compile "$VAR". |
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 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 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
|
1705 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 char_u *start = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 int len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 char_u *name; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1711 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 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
|
1713 if (len == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 { |
27041
fc19375787dd
patch 8.2.4049: Vim9: reading before the start of the line with "$"
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
1715 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
|
1716 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 // 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
|
1720 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
|
1721 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
|
1722 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 /* |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1727 * 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
|
1728 */ |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1729 static int |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1730 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
|
1731 { |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1732 typval_T tv; |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1733 int ret; |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1734 int quote; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1735 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
|
1736 int count = 0; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1737 char_u *p; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1738 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1739 // *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
|
1740 ++*arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1741 quote = **arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1742 ++*arg; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1743 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1744 for (;;) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1745 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1746 // 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
|
1747 // "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
|
1748 if (quote == '"') |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1749 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
|
1750 else |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1751 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
|
1752 if (ret == FAIL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1753 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1754 if (evaluate) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1755 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1756 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
|
1757 || (**arg != '{' && count == 0)) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1758 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1759 // 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
|
1760 // one |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1761 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
|
1762 return FAIL; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1763 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
|
1764 ++count; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1765 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1766 clear_tv(&tv); |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1767 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1768 |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1769 if (**arg != '{') |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1770 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1771 // found terminating quote |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1772 ++*arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1773 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1774 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1775 |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1776 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
|
1777 if (p == NULL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1778 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1779 ret = FAIL; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1780 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1781 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1782 ++count; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1783 *arg = p; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1784 } |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1785 |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1786 if (ret == FAIL || !evaluate) |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1787 return ret; |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1788 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1789 // 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
|
1790 if (count > 1) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1791 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
|
1792 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1793 return OK; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1794 } |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1795 |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1796 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 * Compile "@r". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 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
|
1801 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 int ret; |
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 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 if (**arg == NUL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 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
|
1808 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 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
|
1811 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 emsg_invreg(**arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 return FAIL; |
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 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
|
1816 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 return ret; |
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 |
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 * 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
|
1822 * 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
|
1823 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 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
|
1826 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 char_u *p = *end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1828 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 // 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
|
1830 while (p > start) |
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 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 if (*p == '-' || *p == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1835 // 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
|
1836 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
|
1837 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 if (*p == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 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
|
1840 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 varnumber_T val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 int error = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 // 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
|
1847 // here |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 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
|
1849 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1850 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
|
1851 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 if (error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1853 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1854 if (*p == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1855 val = -val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 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
|
1857 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
|
1858 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 else if (numeric_only) |
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 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 else if (*p == '!') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 int v = tv2bool(rettv); |
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 // '!' 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
|
1870 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 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
|
1872 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
|
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 *end = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 * 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
|
1881 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 static void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 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
|
1884 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 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
|
1886 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1887 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
|
1888 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
|
1889 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1891 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
|
1892 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1893 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
|
1894 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
|
1895 *arg += 7; |
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 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
|
1898 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1899 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
|
1900 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
|
1901 *arg += 6; |
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 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
|
1904 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 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
|
1906 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
|
1907 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 } |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 exprtype_T |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 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
|
1913 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 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
|
1915 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 switch (p[0]) |
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 case '=': if (p[1] == '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 type = EXPR_EQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 else if (p[1] == '~') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 type = EXPR_MATCH; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 case '!': if (p[1] == '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 type = EXPR_NEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 else if (p[1] == '~') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 type = EXPR_NOMATCH; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 case '>': if (p[1] != '=') |
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 type = EXPR_GREATER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 *len = 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 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 type = EXPR_GEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 case '<': if (p[1] != '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 type = EXPR_SMALLER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 *len = 1; |
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 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 type = EXPR_SEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 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
|
1946 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 // "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
|
1948 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
|
1949 *len = 5; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 i = p[*len]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 if (!isalnum(i) && i != '_') |
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 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
|
1954 *type_is = TRUE; |
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1958 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 return type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 * 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
|
1964 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 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
|
1967 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 evalarg_T evalarg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 init_evalarg(&evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 evalarg.eval_cctx = cctx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 skip_expr(arg, &evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 * 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
|
1978 * 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
|
1979 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 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
|
1982 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 type_T *type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
1985 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
|
1986 if (type == &t_bool) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1989 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
|
1990 || 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
|
1991 || 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
|
1992 || 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
|
1993 || 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
|
1994 // 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
|
1995 // 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
|
1996 return generate_COND2BOOL(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 |
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
|
1998 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
|
1999 } |
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 * 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
|
2003 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 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
|
2006 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 char_u buf[10]; |
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 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
|
2010 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
|
2011 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 * 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
|
2015 * 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
|
2016 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2017 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 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
|
2019 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 char_u *p = *end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 // 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
|
2023 while (p > start) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 while (VIM_ISWHITE(*p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2027 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 if (*p == '-' || *p == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 { |
31549
6f1cbee3d652
patch 9.0.1107: float constant not recognized as float
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
2030 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
|
2031 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
|
2032 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
|
2033 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2034 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2035 // 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
|
2036 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
|
2037 return FAIL; |
26662
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 else if (numeric_only) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2041 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 break; |
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 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2046 int invert = *p == '!'; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2048 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
|
2049 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 if (p[-1] == '!') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2051 invert = !invert; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2053 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2054 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
|
2055 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2056 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2057 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2058 *end = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2059 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2060 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2061 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2062 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2063 * Compile "(expression)": recursive! |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2064 * Return FAIL/OK. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2065 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2066 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2067 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
|
2068 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2069 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2070 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
|
2071 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 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
|
2073 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 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
|
2075 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2076 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
|
2077 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2078 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2079 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2080 // 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
|
2081 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
|
2082 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 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
|
2084 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2085 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
|
2086 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 if (**arg == ')') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2088 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 else if (ret == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 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
|
2092 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2093 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2095 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2096 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2097 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
|
2098 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2100 * 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
|
2101 * 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
|
2102 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2103 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2104 compile_subscript( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2105 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2106 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2107 char_u *start_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2108 char_u **end_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2109 ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2111 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
|
2112 int keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2114 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 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
|
2117 type_T *type; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2119 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
|
2120 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 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
|
2122 |
30930
cbfbf0e17cd0
patch 9.0.0799: in compiled function ->() on next line not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30888
diff
changeset
|
2123 // 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
|
2124 // 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
|
2125 // 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
|
2126 if (next != NULL && |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2127 ((next[0] == '-' && next[1] == '>' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2128 && (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
|
2129 || next[2] == '(' |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2130 || 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
|
2131 || (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
|
2132 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 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
|
2134 if (next == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 *arg = next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 // 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
|
2142 // 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
|
2143 if (**arg == '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2144 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2145 int argcount = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2146 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2147 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
|
2148 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2149 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
|
2150 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 // 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
|
2152 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
|
2153 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 *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
|
2155 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
|
2156 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 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
|
2158 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2159 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2162 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
|
2163 return FAIL; |
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 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
|
2167 { |
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
|
2168 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
|
2169 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
|
2170 char_u *paren; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 |
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
|
2172 // something->method() |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 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
|
2174 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 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
|
2176 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 // Apply the '!', '-' and '+' first: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2178 // -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
|
2179 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
|
2180 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2181 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2182 p += 2; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 *arg = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2184 // 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
|
2185 |
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
|
2186 // 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
|
2187 // 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
|
2188 // 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
|
2189 // 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
|
2190 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
|
2191 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
|
2192 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
|
2193 { |
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
|
2194 // 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
|
2195 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
|
2196 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
|
2197 { |
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
|
2198 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
|
2199 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
|
2200 } |
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
|
2201 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
|
2202 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
|
2203 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
|
2204 ; |
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
|
2205 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
|
2206 { |
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
|
2207 // 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
|
2208 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
|
2209 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
|
2210 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
|
2211 } |
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
|
2212 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
|
2213 { |
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
|
2214 // 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
|
2215 // 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
|
2216 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
|
2217 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
|
2218 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
|
2219 { |
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
|
2220 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
|
2221 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
|
2222 } |
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
|
2223 } |
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
|
2224 } |
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
|
2225 |
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
|
2226 if (alt != 1) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 int argcount = 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 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
|
2230 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
|
2231 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
|
2232 int expr_isn_end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 int arg_isn_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 |
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
|
2235 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
|
2236 { |
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
|
2237 // 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
|
2238 // 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
|
2239 // |
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
|
2240 // 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
|
2241 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
|
2242 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
|
2243 } |
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
|
2244 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
|
2245 { |
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
|
2246 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
|
2247 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
|
2248 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
|
2249 |
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
|
2250 *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
|
2251 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2252 // 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
|
2253 ++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
|
2254 |
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
|
2255 // 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
|
2256 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
|
2257 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2258 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
|
2259 || *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
|
2260 *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
|
2261 --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
|
2262 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
|
2263 |
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
|
2264 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
|
2265 { |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
2266 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
|
2267 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
|
2268 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
|
2269 } |
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
|
2270 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2272 // Compile the arguments. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 if (**arg != '(') |
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 (*skipwhite(*arg) == '(') |
26887
612339679616
patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
2276 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
|
2277 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2278 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
|
2279 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2280 } |
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
|
2281 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2282 // 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
|
2283 // 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
|
2284 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
|
2285 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2286 *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
|
2287 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
|
2288 == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2289 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2290 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2291 // 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
|
2292 // 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
|
2293 // 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
|
2294 // expects. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2295 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
|
2296 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
|
2297 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2298 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
|
2299 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
|
2300 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
|
2301 type2_T *typep; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2302 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2303 if (isn == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2304 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2305 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
|
2306 + expr_isn_start, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2307 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
|
2308 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
|
2309 + expr_isn_start, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2310 ((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
|
2311 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
|
2312 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
|
2313 + 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
|
2314 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
|
2315 vim_free(isn); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2316 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2317 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
|
2318 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
|
2319 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
|
2320 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
|
2321 ((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
|
2322 sizeof(type2_T) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2323 * (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
|
2324 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
|
2325 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
|
2326 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
|
2327 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2328 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2329 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
|
2330 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
|
2331 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 } |
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
|
2333 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2334 if (keeping_dict) |
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 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2337 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
|
2338 return FAIL; |
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2341 else if (**arg == '[') |
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 int is_slice = FALSE; |
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 // list index: list[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2346 // dict member: dict[key] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2347 // string index: text[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2348 // blob index: blob[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2349 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
|
2350 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 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
|
2352 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 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
|
2355 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2357 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 // 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
|
2359 generate_PUSHNR(cctx, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2360 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2361 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2362 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2363 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
|
2364 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2365 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2366 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2367 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
|
2368 ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2369 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2370 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2371 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
|
2372 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2373 *arg = skipwhite(*arg); |
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 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2376 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2377 is_slice = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2378 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2379 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
|
2380 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2381 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
|
2382 ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 return FAIL; |
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 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
|
2386 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2387 if (**arg == ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 // 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
|
2389 generate_PUSHNR(cctx, -1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2391 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2392 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
|
2393 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2394 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
|
2395 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2396 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2398 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2399 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2400 if (**arg != ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2401 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2402 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
|
2403 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2404 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2405 *arg = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2408 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2409 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 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
|
2411 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2412 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2413 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
|
2414 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2415 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 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
|
2417 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2418 // dictionary member: dict.name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2419 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
|
2420 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2421 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
|
2422 |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2423 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
|
2424 && (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
|
2425 || 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
|
2426 { |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2427 // 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
|
2428 // 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
|
2429 // 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
|
2430 // 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
|
2431 // 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
|
2432 *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
|
2433 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
|
2434 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2435 } |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2436 else |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2437 { |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2438 *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
|
2439 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
|
2440 { |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2441 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
|
2442 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
|
2443 } |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2444 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
|
2445 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
|
2446 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
|
2447 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
|
2448 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
|
2449 { |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2450 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
|
2451 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
|
2452 } |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2453 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
|
2454 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
|
2455 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
|
2456 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
|
2457 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
|
2458 *arg = p; |
26662
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 break; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 // 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
|
2466 // 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
|
2467 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
|
2468 && 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
|
2469 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2470 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2471 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2472 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2473 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2474 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2475 * 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
|
2476 * "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
|
2477 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2478 * 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
|
2479 * 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
|
2480 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2481 * 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
|
2482 */ |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2485 * number number constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2486 * 0zFFFFFFFF Blob constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2487 * "string" string constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2488 * 'string' literal string constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2489 * &option-name option value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2490 * @r register contents |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2491 * identifier variable value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2492 * function() function call |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2493 * $VAR environment variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2494 * (expression) nested expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2495 * [expr, expr] List |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2496 * {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
|
2497 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2498 * Also handle: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2499 * ! in front logical NOT |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2500 * - in front unary minus |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2501 * + 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
|
2502 * 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
|
2503 * 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
|
2504 * 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
|
2505 * trailing ->name() method call |
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 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2508 compile_expr9( |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2509 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2510 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2511 ppconst_T *ppconst) |
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 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
|
2514 int ret = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2515 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
|
2516 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
|
2517 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2518 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
|
2519 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2520 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2521 * 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
|
2522 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2523 start_leader = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2524 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
|
2525 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2526 end_leader = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2527 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2528 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
|
2529 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2530 { |
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 * Number constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2533 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2534 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
|
2535 case '1': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2536 case '2': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2537 case '3': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2538 case '4': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2539 case '5': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2540 case '6': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2541 case '7': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2542 case '8': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2543 case '9': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2544 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
|
2545 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2546 // 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
|
2547 // 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
|
2548 // '!'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2549 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
|
2550 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
|
2551 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2552 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2553 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2554 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2555 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2558 * String constant: "string". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2559 */ |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
2560 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
|
2561 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2562 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2565 * 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
|
2566 */ |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
2567 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
|
2568 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2569 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2572 * Constant Vim variable. |
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 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
|
2575 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2576 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2579 * "true" constant |
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 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
|
2582 && !eval_isnamec((*arg)[4])) |
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 *arg += 4; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2585 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
|
2586 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
|
2587 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2588 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2589 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2590 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2591 |
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 * "false" constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2594 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2595 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
|
2596 && !eval_isnamec((*arg)[5])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2597 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2598 *arg += 5; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2599 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
|
2600 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
|
2601 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2602 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2603 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2604 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2605 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 /* |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2607 * "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
|
2608 */ |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2609 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
|
2610 { |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2611 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
|
2612 int len; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2613 |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2614 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
|
2615 ; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2616 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
|
2617 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
|
2618 ret = NOTDONE; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2619 else |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2620 *arg += len + 4; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2622 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2624 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2627 * List: [expr, expr] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2628 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 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
|
2630 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 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
|
2632 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2635 * 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
|
2636 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2637 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
|
2638 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 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
|
2640 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2641 |
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 * Option value: &name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2644 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 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
|
2646 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 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
|
2648 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2650 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 * Environment variable: $VAR. |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2652 * 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
|
2653 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2654 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
|
2655 return FAIL; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2656 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
|
2657 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
|
2658 else |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2659 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
|
2660 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 * Register contents: @r. |
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 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
|
2666 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 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
|
2668 break; |
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 * nested expression: (expression). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2671 * lambda: (arg, arg) => expr |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 * funcref: (arg, arg) => { statement } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2673 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 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
|
2675 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
|
2676 if (ret == NOTDONE) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 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
|
2678 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 default: ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 if (ret == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 return FAIL; |
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 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
|
2687 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 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
|
2689 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2690 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 // 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
|
2692 // 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
|
2693 ++ppconst->pp_used; |
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 else if (ret == NOTDONE) |
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 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2698 int r; |
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 (!eval_isnamec1(**arg)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2701 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 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
|
2703 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 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
|
2705 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
|
2706 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 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
|
2708 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2712 // "name" or "name()" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 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
|
2714 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
|
2715 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2716 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
|
2717 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2720 if (*p == '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2721 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2722 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
|
2723 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2724 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2726 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
|
2727 && 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
|
2728 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2729 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
|
2730 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2731 if (r == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2732 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 } |
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 // Handle following "[]", ".member", etc. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 // 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
|
2737 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
|
2738 ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2739 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2740 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
|
2741 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 // 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
|
2743 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
|
2744 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
|
2745 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2746 return OK; |
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 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
|
2749 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2750 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2751 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2752 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2753 /* |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2754 * <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
|
2755 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2756 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2757 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
|
2758 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2759 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
|
2760 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 // Recognize <type> |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 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
|
2763 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2764 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2765 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
|
2766 if (want_type == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2767 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2769 if (**arg != '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2771 if (*skipwhite(*arg) == '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 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
|
2773 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2774 emsg(_(e_missing_gt)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2776 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2777 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2778 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
|
2779 return FAIL; |
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 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2782 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
|
2783 return FAIL; |
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 (want_type != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2786 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2787 type_T *actual; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2788 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
|
2789 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2790 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
|
2791 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
|
2792 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
|
2793 { |
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
|
2794 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
|
2795 -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
|
2796 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2797 } |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2803 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2804 * * number multiplication |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2805 * / number division |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 * % number modulo |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2807 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2808 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2809 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
|
2810 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 char_u *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2812 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2813 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
|
2814 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2815 // get the first expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2816 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
|
2817 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2818 |
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 * 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
|
2821 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2822 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2823 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2824 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
|
2825 if (*op != '*' && *op != '/' && *op != '%') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2826 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 if (next != NULL) |
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 *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
|
2830 op = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2831 } |
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 (!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
|
2834 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2835 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
|
2836 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2837 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2838 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
|
2839 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2840 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2841 // get the second expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2842 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
|
2843 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2844 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2845 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
|
2846 && 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
|
2847 && 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
|
2848 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2849 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
|
2850 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
|
2851 varnumber_T res = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2852 int failed = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2853 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2854 // 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
|
2855 switch (*op) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2856 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2857 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
|
2858 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2859 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
|
2860 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
|
2861 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2862 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
|
2863 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
|
2864 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2865 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2866 if (failed) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2867 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2868 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
|
2869 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2870 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2871 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2872 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2873 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2874 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
|
2875 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2876 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2877 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2878 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2879 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2880 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2881 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2882 * + 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
|
2883 * - number subtraction |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2884 * .. string concatenation |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2885 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2886 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2887 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
|
2888 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2889 char_u *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2890 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2891 int oplen; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2892 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
|
2893 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2894 // get the first variable |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2895 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
|
2896 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2897 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2898 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2899 * 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
|
2900 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2901 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2902 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2903 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
|
2904 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
|
2905 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2906 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
|
2907 // 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
|
2908 // But ".." is concatenation. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2909 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2910 oplen = (*op == '.' ? 2 : 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2911 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2912 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2913 *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
|
2914 op = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2915 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2916 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2917 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
|
2918 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2919 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
|
2920 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2921 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2922 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2923 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
|
2924 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2925 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2926 // get the second expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2927 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
|
2928 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2929 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2930 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
|
2931 && (*op == '.' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2932 ? (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
|
2933 && 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
|
2934 : (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
|
2935 && 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
|
2936 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2937 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
|
2938 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
|
2939 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2940 // 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
|
2941 if (*op == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2942 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
|
2943 else if (*op == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2944 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
|
2945 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2946 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2947 // concatenate constant strings |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2948 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
|
2949 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
|
2950 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
|
2951 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2952 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
|
2953 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
|
2954 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2955 clear_ppconst(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2956 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2957 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2958 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
|
2959 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
|
2960 vim_free(s1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2961 vim_free(s2); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2962 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2963 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2964 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2965 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2966 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2967 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2968 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
|
2969 if (*op == '.') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2970 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2971 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
|
2972 || 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
|
2973 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
|
2974 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
|
2975 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2976 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2977 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2978 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
|
2979 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2980 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2981 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2982 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2983 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2984 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 /* |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2986 * expr6a >> expr6b |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2987 * expr6a << expr6b |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2988 * |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2989 * Produces instructions: |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2990 * OPNR bitwise left or right shift |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2991 */ |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2992 static int |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2993 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
|
2994 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2995 exprtype_T type = EXPR_UNKNOWN; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2996 char_u *p; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2997 char_u *next; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2998 int len = 2; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2999 int ppconst_used = ppconst->pp_used; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3000 isn_T *isn; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3001 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3002 // get the first variable |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3003 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
|
3004 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3005 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3006 /* |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3007 * 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
|
3008 */ |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3009 for (;;) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3010 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3011 type = EXPR_UNKNOWN; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3012 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3013 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
|
3014 if (p[0] == '<' && p[1] == '<') |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3015 type = EXPR_LSHIFT; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3016 else if (p[0] == '>' && p[1] == '>') |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3017 type = EXPR_RSHIFT; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3018 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3019 if (type == EXPR_UNKNOWN) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3020 return OK; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3021 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3022 // 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
|
3023 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
|
3024 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
3025 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
|
3026 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3027 // left operand should be a number |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3028 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
|
3029 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3030 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3031 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3032 else |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3033 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3034 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
|
3035 |
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
|
3036 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
|
3037 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3038 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
|
3039 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3040 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3041 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3042 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3043 if (next != NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3044 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3045 *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
|
3046 p = skipwhite(*arg); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3047 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3048 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3049 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
|
3050 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3051 error_white_both(p, len); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3052 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3053 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3054 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3055 // get the second variable |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3056 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
|
3057 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3058 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3059 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
|
3060 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3061 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3062 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
|
3063 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
3064 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
|
3065 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
|
3066 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3067 // 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
|
3068 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
|
3069 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3070 // 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
|
3071 if (tv2->v_type != VAR_NUMBER) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3072 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
|
3073 else |
30986
360f286b5869
patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents:
30930
diff
changeset
|
3074 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
|
3075 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3076 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3077 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3078 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
|
3079 tv1->vval.v_number = 0; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3080 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
|
3081 tv1->vval.v_number = |
3043a3e2ef95
patch 8.2.5006: asan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
28966
diff
changeset
|
3082 (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
|
3083 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
|
3084 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
|
3085 (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
|
3086 clear_tv(tv2); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3087 --ppconst->pp_used; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3088 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3089 else |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3090 { |
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
|
3091 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
|
3092 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
|
3093 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3094 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
|
3095 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3096 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3097 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3098 generate_ppconst(cctx, ppconst); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3099 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3100 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
|
3101 if (isn == NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3102 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3103 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3104 if (isn != NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3105 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
|
3106 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3107 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3108 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3109 return OK; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3110 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3111 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3112 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3113 * expr5a == expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3114 * expr5a =~ expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3115 * expr5a != expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3116 * expr5a !~ expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3117 * expr5a > expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3118 * expr5a >= expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3119 * expr5a < expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3120 * expr5a <= expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3121 * expr5a is expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3122 * expr5a isnot expr5b |
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 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3125 * 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
|
3126 * 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
|
3127 * 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
|
3128 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3129 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3130 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
|
3131 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3132 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
|
3133 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3135 int len = 2; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3136 int type_is = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3137 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
|
3138 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3139 // get the first variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3140 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
|
3141 return FAIL; |
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 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
|
3144 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3145 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
|
3146 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3147 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3148 * 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
|
3149 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3150 if (type != EXPR_UNKNOWN) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3151 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3152 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
|
3153 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3154 if (next != NULL) |
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 *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
|
3157 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3158 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3159 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
|
3160 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3161 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
|
3162 return FAIL; |
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 // 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
|
3165 if (p[len] == '?') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3166 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3167 ic = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3168 ++len; |
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 // 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
|
3171 else if (p[len] == '#') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3172 ++len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3173 // nothing appended: match case |
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 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
|
3176 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3177 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
|
3178 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3179 } |
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 // get the second variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3182 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
|
3183 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3184 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3185 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
|
3186 return FAIL; |
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 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
|
3189 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
3190 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
|
3191 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
|
3192 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3193 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3194 // 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
|
3195 // 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
|
3196 // strict than typval_compare(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3197 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
|
3198 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3199 else |
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 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
|
3202 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
|
3203 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
|
3204 ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3205 clear_tv(tv2); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3206 --ppconst->pp_used; |
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 return ret; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3211 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3212 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
|
3213 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3214 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3215 return OK; |
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 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
|
3219 |
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 * Compile || or &&. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3222 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3223 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3224 compile_and_or( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3225 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3226 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3227 char *op, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3228 ppconst_T *ppconst, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3229 int ppconst_used UNUSED) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3230 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3231 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3232 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
|
3233 int opchar = *op; |
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 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
|
3236 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3237 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
|
3238 garray_T end_ga; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3239 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
|
3240 |
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 * 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
|
3243 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3244 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
|
3245 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
|
3246 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3247 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
|
3248 long save_sourcing_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3249 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
|
3250 int save_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3251 int const_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3252 int status; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3253 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
|
3254 ? 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
|
3255 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3256 if (next != NULL) |
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 *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
|
3259 p = skipwhite(*arg); |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3262 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
|
3263 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3264 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
|
3265 op, p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3266 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3267 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3268 } |
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 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
|
3271 SOURCING_LNUM = start_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3272 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
|
3273 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
|
3274 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3275 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
|
3276 if (status != FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3277 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3278 // 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
|
3279 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
|
3280 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3281 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
|
3282 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
|
3283 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3284 if ((is_true && opchar == '|') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3285 || (!is_true && opchar == '&')) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3286 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3287 // 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
|
3288 // 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
|
3289 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
|
3290 clear_tv(tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3291 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
|
3292 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
|
3293 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3294 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3295 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3296 // 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
|
3297 // needs to be evaluated. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3298 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3299 jump_when = JUMP_NEVER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3300 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3301 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3302 else |
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 // 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
|
3305 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
|
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 if (status != FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3309 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
|
3310 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
|
3311 if (status == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3312 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3313 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3314 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3315 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3316 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3317 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
|
3318 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3319 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
|
3320 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3321 *(((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
|
3322 ++end_ga.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3323 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3324 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
|
3325 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3326 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3327 // eval the next expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3328 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
|
3329 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
|
3330 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3331 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3332 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3333 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3334 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3335 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
|
3336 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
|
3337 : 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
|
3338 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3339 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3340 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3341 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3342 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3343 // "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
|
3344 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
|
3345 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3346 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
|
3347 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3348 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
|
3349 && (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
|
3350 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3351 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
|
3352 ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3353 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
|
3354 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3355 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3356 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3357 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
|
3358 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3359 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3360 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
|
3361 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3362 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3363 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3366 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
|
3367 // 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
|
3368 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
|
3369 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3370 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3372 } |
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 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
|
3375 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3376 // 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
|
3377 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3378 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
|
3379 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3380 isn_T *isn; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3381 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3382 --end_ga.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3383 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
|
3384 + *(((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
|
3385 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
|
3386 } |
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 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3389 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3390 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
|
3391 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3392 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3393 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3394 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3397 * 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
|
3398 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3399 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3400 * 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
|
3401 * 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
|
3402 * 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
|
3403 * 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
|
3404 * 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
|
3405 * 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
|
3406 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3407 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3408 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3409 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
|
3410 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3411 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
|
3412 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3413 // get the first variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3414 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
|
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 // || 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
|
3418 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
|
3419 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3422 * 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
|
3423 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3424 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3425 * 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
|
3426 * 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
|
3427 * 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
|
3428 * 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
|
3429 * 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
|
3430 * 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
|
3431 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3432 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3433 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3434 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
|
3435 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3436 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
|
3437 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3438 // eval the first expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3439 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
|
3440 return FAIL; |
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 // || 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
|
3443 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
|
3444 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3445 |
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 * 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
|
3448 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3449 * 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
|
3450 * 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
|
3451 * EVAL expr1a |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3452 * JUMP_ALWAYS end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3453 * alt: EVAL expr1b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3454 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3455 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3456 * Toplevel expression: expr2 ?? expr1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3457 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3458 * 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
|
3459 * 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
|
3460 * EVAL expr1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3461 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3462 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3463 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3464 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
|
3465 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3466 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3467 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
|
3468 char_u *next; |
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 // 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
|
3471 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
|
3472 { |
27539
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27505
diff
changeset
|
3473 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
|
3474 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3475 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
|
3476 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
|
3477 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3478 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3479 // Evaluate the first expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3480 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
|
3481 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3482 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3483 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
|
3484 if (*p == '?') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3485 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3486 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
|
3487 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
|
3488 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
|
3489 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
|
3490 int end_idx = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3491 isn_T *isn; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3492 type_T *type1 = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3493 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
|
3494 int const_value = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3495 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
|
3496 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3497 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3498 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3499 *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
|
3500 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3501 } |
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 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
|
3504 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3505 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
|
3506 op_falsy ? "??" : "?", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3507 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3508 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3509 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3510 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
|
3511 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3512 // 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
|
3513 // 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
|
3514 has_const_expr = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3515 if (op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3516 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
|
3517 else |
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 int error = FALSE; |
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 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
|
3522 &error); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3523 if (error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3524 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3525 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3526 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
|
3527 (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
|
3528 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3529 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
|
3530 // "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
|
3531 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3532 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3533 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3534 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
|
3535 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3536 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3537 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3538 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3539 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3540 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3541 if (op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3542 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
|
3543 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
|
3544 ? 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
|
3545 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
|
3546 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
|
3547 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3548 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3549 // 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
|
3550 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
|
3551 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3552 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
|
3553 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3554 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3555 if (!has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3556 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3557 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3558 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3559 if (!op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3560 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3561 // 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
|
3562 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
|
3563 --stack->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3564 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3565 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
|
3566 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
|
3567 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3568 // 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
|
3569 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
|
3570 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
|
3571 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3572 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3573 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3574 if (!op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3575 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3576 // Check for the ":". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3577 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
|
3578 if (*p != ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3579 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3580 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
|
3581 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3582 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3583 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3584 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3585 *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
|
3586 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3587 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3588 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3589 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
|
3590 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3591 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
|
3592 ":", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3593 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3594 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3595 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3596 // evaluate the third expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3597 if (has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3598 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
|
3599 ? SKIP_YES : SKIP_NOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3600 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
|
3601 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3602 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
|
3603 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3604 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3605 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3606 if (!has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3607 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3608 type_T **typep; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3609 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3610 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
|
3611 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
|
3612 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3613 // 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
|
3614 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
|
3615 + 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
|
3616 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
|
3617 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3618 // 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
|
3619 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
|
3620 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
|
3621 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3622 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3623 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
|
3624 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3625 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3626 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3627 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3628 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3629 * Toplevel expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3630 * 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
|
3631 * Returns OK or FAIL. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3632 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3633 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3634 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
|
3635 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3636 ppconst_T ppconst; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3637 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3638 CLEAR_FIELD(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3639 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
|
3640 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3641 clear_ppconst(&ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3642 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3643 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3644 if (is_const != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3645 *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
|
3646 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
|
3647 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3648 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3649 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3650 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3651 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3652 * Toplevel expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3653 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3654 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3655 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
|
3656 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3657 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
|
3658 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3659 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3660 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3661 #endif // defined(FEAT_EVAL) |