Mercurial > vim
annotate src/vim9expr.c @ 33311:1f3bcb7f3bd0 v9.0.1921
patch 9.0.1921: not possible to use the jumplist like a stack
Commit: https://github.com/vim/vim/commit/87018255e3ad0f4dfa03e20318836d24af721caf
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Sep 20 20:20:04 2023 +0200
patch 9.0.1921: not possible to use the jumplist like a stack
Problem: not possible to use the jumplist like a stack
Solution: Add the 'jumpoptions' setting to make the jumplist
a stack.
Add an option for using jumplist like tag stack
related: #7738
closes: #13134
ported from NeoVim:
- https://neovim.io/doc/user/motion.html#jumplist-stack
- neovim/neovim@39094b3
- neovim/neovim#11530
- https://vi.stackexchange.com/questions/18344/how-to-change-jumplist-behavior
Based on the feedback in the previous PR, it looks like many people like
this option.
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: butwerenotthereyet <58348703+butwerenotthereyet@users.noreply.github.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 20 Sep 2023 20:30:06 +0200 |
parents | 0c3553cfe22e |
children | 4e531adb3fac |
rev | line source |
---|---|
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
29759
d19adfd545e2
patch 9.0.0219: cannot make a funcref with "s:func" in a def function
Bram Moolenaar <Bram@vim.org>
parents:
28992
diff
changeset
|
11 * vim9expr.c: Dealing with compiled function expressions |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #define USING_FLOAT_STUFF |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 #include "vim.h" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 #if defined(FEAT_EVAL) || defined(PROTO) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 // When not generating protos this is included in proto.h |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 #ifdef PROTO |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 # include "vim9.h" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 #endif |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
24 // flag passed from compile_subscript() to compile_load_scriptvar() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
25 static int paren_follows_after_expr = 0; |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
26 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 * Generate code for any ppconst entries. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 generate_ppconst(cctx_T *cctx, ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 int ret = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 int save_skip = cctx->ctx_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 cctx->ctx_skip = SKIP_NOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 for (i = 0; i < ppconst->pp_used; ++i) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 if (generate_tv_PUSH(cctx, &ppconst->pp_tv[i]) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 ppconst->pp_used = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 cctx->ctx_skip = save_skip; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 * Check that the last item of "ppconst" is a bool, if there is an item. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 check_ppconst_bool(ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 if (ppconst->pp_used > 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used - 1]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 where_T where = WHERE_INIT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 return check_typval_type(&t_bool, tv, where); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 * Clear ppconst constants. Used when failing. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 clear_ppconst(ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 for (i = 0; i < ppconst->pp_used; ++i) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 clear_tv(&ppconst->pp_tv[i]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 ppconst->pp_used = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 * Compile getting a member from a list/dict/string/blob. Stack has the |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 * indexable value and the index or the two indexes of a slice. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 * "keeping_dict" is used for dict[func](arg) to pass dict to func. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 compile_member(int is_slice, int *keeping_dict, cctx_T *cctx) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
83 type2_T *typep; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 garray_T *stack = &cctx->ctx_type_stack; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 vartype_T vartype; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 type_T *idxtype; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 // We can index a list, dict and blob. If we don't know the type |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 // we can use the index value type. If we still don't know use an "ANY" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 // instruction. |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
91 // TODO: what about the decl type? |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
92 typep = (((type2_T *)stack->ga_data) + stack->ga_len - (is_slice ? 3 : 2)); |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
93 vartype = typep->type_curr->tt_type; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
94 idxtype = (((type2_T *)stack->ga_data) + stack->ga_len - 1)->type_curr; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 // If the index is a string, the variable must be a Dict. |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
96 if ((typep->type_curr->tt_type == VAR_ANY |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
97 || typep->type_curr->tt_type == VAR_UNKNOWN) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
98 && idxtype == &t_string) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 vartype = VAR_DICT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 if (vartype == VAR_STRING || vartype == VAR_LIST || vartype == VAR_BLOB) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 { |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
102 if (need_type(idxtype, &t_number, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
103 -1, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
107 idxtype = get_type_on_stack(cctx, 1); |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
108 if (need_type(idxtype, &t_number, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
109 -2, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 if (vartype == VAR_DICT) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 emsg(_(e_cannot_slice_dictionary)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 } |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
121 if (typep->type_curr->tt_type == VAR_DICT) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
123 typep->type_curr = typep->type_curr->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
124 if (typep->type_curr == &t_unknown) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 // empty dict was used |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
126 typep->type_curr = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
127 if (typep->type_decl->tt_type == VAR_DICT) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
128 { |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
129 typep->type_decl = typep->type_decl->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
130 if (typep->type_decl == &t_unknown) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
131 // empty dict was used |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
132 typep->type_decl = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
133 } |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
134 else |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
135 typep->type_decl = typep->type_curr; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 { |
31551
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
139 if (need_type(typep->type_curr, &t_dict_any, FALSE, |
67d9fbe516a3
patch 9.0.1108: type error when using "any" type and adding to float
Bram Moolenaar <Bram@vim.org>
parents:
31549
diff
changeset
|
140 -2, 0, cctx, FALSE, FALSE) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 return FAIL; |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
142 typep->type_curr = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
143 typep->type_decl = &t_any; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 } |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
145 if (may_generate_2STRING(-1, FALSE, cctx) == FAIL |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
146 || generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 if (keeping_dict != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 *keeping_dict = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 else if (vartype == VAR_STRING) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
153 typep->type_curr = &t_string; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
154 typep->type_decl = &t_string; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 if ((is_slice |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 ? generate_instr_drop(cctx, ISN_STRSLICE, 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 : generate_instr_drop(cctx, ISN_STRINDEX, 1)) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 else if (vartype == VAR_BLOB) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
164 typep->type_curr = &t_blob; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
165 typep->type_decl = &t_blob; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 if (generate_instr_drop(cctx, ISN_BLOBSLICE, 2) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
171 typep->type_curr = &t_number; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
172 typep->type_decl = &t_number; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 if (generate_instr_drop(cctx, ISN_BLOBINDEX, 1) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 } |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
177 else if (vartype == VAR_LIST || typep->type_curr->tt_type == VAR_ANY |
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
178 || typep->type_curr->tt_type == VAR_UNKNOWN) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 if (is_slice) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 if (generate_instr_drop(cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 vartype == VAR_LIST ? ISN_LISTSLICE : ISN_ANYSLICE, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 2) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 return FAIL; |
27573
68eac9355e49
patch 8.2.4313: Vim9: cannot change type of list after making a slice
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
186 // a copy is made so the member type is no longer declared |
68eac9355e49
patch 8.2.4313: Vim9: cannot change type of list after making a slice
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
187 if (typep->type_decl->tt_type == VAR_LIST) |
68eac9355e49
patch 8.2.4313: Vim9: cannot change type of list after making a slice
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
188 typep->type_decl = &t_list_any; |
31010
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
189 |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
190 // a copy is made, the composite is no longer "const" |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
191 if (typep->type_curr->tt_flags & TTFLAG_CONST) |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
192 { |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
193 type_T *type = copy_type(typep->type_curr, cctx->ctx_type_list); |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
194 |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
195 if (type != typep->type_curr) // did get a copy |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
196 { |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
197 type->tt_flags &= ~(TTFLAG_CONST | TTFLAG_STATIC); |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
198 typep->type_curr = type; |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
199 } |
4b9b76aac30c
patch 9.0.0840: cannot change a slice of a const list
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
200 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
204 if (typep->type_curr->tt_type == VAR_LIST) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 { |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
206 typep->type_curr = typep->type_curr->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
207 if (typep->type_curr == &t_unknown) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 // empty list was used |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
209 typep->type_curr = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
210 if (typep->type_decl->tt_type == VAR_LIST) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
211 { |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
212 typep->type_decl = typep->type_decl->tt_member; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
213 if (typep->type_decl == &t_unknown) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
214 // empty list was used |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
215 typep->type_decl = &t_any; |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
216 } |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
217 else |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
218 typep->type_decl = typep->type_curr; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 if (generate_instr_drop(cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 vartype == VAR_LIST ? ISN_LISTINDEX : ISN_ANYINDEX, 1) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 switch (vartype) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 case VAR_FUNC: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 case VAR_PARTIAL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 emsg(_(e_cannot_index_a_funcref)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 case VAR_BOOL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 case VAR_SPECIAL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 case VAR_JOB: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 case VAR_CHANNEL: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 case VAR_INSTR: |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31010
diff
changeset
|
239 case VAR_CLASS: |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31010
diff
changeset
|
240 case VAR_OBJECT: |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 case VAR_UNKNOWN: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 case VAR_ANY: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 case VAR_VOID: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 emsg(_(e_cannot_index_special_variable)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 default: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 emsg(_(e_string_list_dict_or_blob_required)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 /* |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
255 * 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
|
256 * parent classes. |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
257 */ |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
258 static int |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
259 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
|
260 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
261 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
|
262 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
263 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
|
264 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
265 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
|
266 while (clp != NULL) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
267 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
268 if (clp == cl) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
269 return TRUE; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
270 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
|
271 } |
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 return FALSE; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
276 } |
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 /* |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
279 * 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
|
280 */ |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
281 static int |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
282 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
|
283 { |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
284 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
|
285 { |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
286 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
|
287 return FAIL; |
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 |
32005
ef644af2c330
patch 9.0.1334: using tt_member for the class leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
31982
diff
changeset
|
290 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
|
291 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
|
292 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
|
293 { |
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 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
|
295 { |
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
|
296 emsg(_(e_using_super_not_in_class_function)); |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
297 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
|
298 } |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
299 is_super = TRUE; |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
300 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
|
301 // 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
|
302 --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
|
303 } |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
304 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
|
305 { |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
306 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
|
307 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
|
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 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
|
310 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
|
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 // 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
|
313 // 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
|
314 --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
|
315 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
|
316 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
317 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
318 } |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
319 |
32088
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
320 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
|
321 { |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
322 // 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
|
323 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
|
324 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
|
325 } |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32005
diff
changeset
|
326 |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
327 ++*arg; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
332 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
|
333 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
334 if (*name_end == '(') |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
335 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
336 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
|
337 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
|
338 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
|
339 |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
340 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
|
341 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 } |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
346 else |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
347 { |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
348 // 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
|
349 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
|
350 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
|
351 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
|
352 } |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
353 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 { |
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 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
|
359 // 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
|
360 // 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
|
361 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
|
362 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
|
363 { |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
364 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
|
365 break; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
366 } |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
367 } |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
368 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
|
369 { |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
370 method_not_found_msg(cl, type->tt_type, name, len); |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
371 return FAIL; |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
372 } |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
373 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
374 // 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
|
375 // 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
|
376 // 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
|
377 // defined. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
378 if (*ufunc->uf_name == '_' && |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
379 ((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
|
380 && !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
|
381 || (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
|
382 && 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
|
383 { |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
384 semsg(_(e_cannot_access_private_method_str), name); |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
385 return FAIL; |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
386 } |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
32840
diff
changeset
|
387 |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
388 // 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
|
389 // 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
|
390 // 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
|
391 *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
|
392 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
|
393 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
|
394 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
|
395 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
396 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
|
397 && (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))) |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32088
diff
changeset
|
398 return generate_CALL(cctx, ufunc, cl, fi, type, argcount); |
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32088
diff
changeset
|
399 return generate_CALL(cctx, ufunc, NULL, 0, type, argcount); |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
400 } |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
401 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
402 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
|
403 { |
33246
877dddec681f
patch 9.0.1895: Vim9: finding object method/member is inefficient
Christian Brabandt <cb@256bit.org>
parents:
33233
diff
changeset
|
404 int m_idx; |
877dddec681f
patch 9.0.1895: Vim9: finding object method/member is inefficient
Christian Brabandt <cb@256bit.org>
parents:
33233
diff
changeset
|
405 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
|
406 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
|
407 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
408 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
|
409 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
410 semsg(_(e_cannot_access_private_member_str), m->ocm_name); |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
411 return FAIL; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
412 } |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
413 |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
414 *arg = name_end; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
415 if (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED)) |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
416 return generate_GET_ITF_MEMBER(cctx, cl, 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
|
417 FALSE); |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
418 return generate_GET_OBJ_MEMBER(cctx, m_idx, m->ocm_type, FALSE); |
33173
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
419 } |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
420 |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
421 // Could be a function 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
|
422 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
|
423 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
|
424 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
425 ufunc_T *fp = cl->class_obj_methods[m_idx]; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
426 if (type->tt_type == VAR_OBJECT |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
427 && (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))) |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
428 return generate_FUNCREF(cctx, fp, cl, m_idx, NULL); |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
429 return generate_FUNCREF(cctx, fp, NULL, 0, NULL); |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
430 } |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
431 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
432 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
|
433 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
434 else |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
435 { |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
436 // 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
|
437 int idx; |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
438 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
|
439 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
|
440 { |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
441 // 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
|
442 // 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
|
443 // it is defined. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
444 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
|
445 { |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
446 semsg(_(e_cannot_access_private_member_str), m->ocm_name); |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
447 return FAIL; |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
448 } |
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
449 |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
450 *arg = name_end; |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
451 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
|
452 } |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
453 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
|
454 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
455 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
456 return FAIL; |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
457 } |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
458 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
459 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 * 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
|
461 * leading "s:". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 * Also finds imported variables. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 compile_load_scriptvar( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 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
|
468 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
|
469 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
|
470 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 scriptitem_T *si; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 imported_T *import; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 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
|
476 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 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
|
478 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
|
479 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 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
|
482 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 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
|
484 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
|
485 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
488 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
|
489 if (import != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 { |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
491 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
|
492 char_u *exp_name; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
493 int cc; |
28271
c84f4e34ba16
patch 8.2.4661: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
494 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
|
495 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
|
496 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
|
497 int res = OK; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
499 // 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
|
500 if (*p != '.') |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
501 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
502 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
|
503 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
504 } |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
505 ++p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
506 if (VIM_ISWHITE(*p)) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
507 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
508 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
|
509 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
510 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
512 // isolate one name |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
513 exp_name = p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
514 while (eval_isnamec(*p)) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
515 ++p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
516 cc = *p; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
517 *p = NUL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
518 |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27043
diff
changeset
|
519 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
|
520 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
|
521 // "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
|
522 // "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
|
523 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
|
524 |
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
|
525 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
|
526 { |
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
|
527 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
|
528 && 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
|
529 { |
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
|
530 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
|
531 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
|
532 |
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
|
533 // 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
|
534 // 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
|
535 // 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 } |
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
|
543 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
|
544 && 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
|
545 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
546 // 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
|
547 // 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
|
548 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
|
549 { |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
550 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
|
551 |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
552 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
|
553 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
|
554 } |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
555 else |
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
556 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
|
557 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
|
558 done = TRUE; |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
559 } |
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
|
560 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
|
561 { |
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
|
562 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
|
563 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
|
564 } |
28249
4b322951ebac
patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
565 } |
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
|
566 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
567 *p = cc; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
568 *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
|
569 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
|
570 return res; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
572 if (idx < 0) |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
573 { |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
574 if (ufunc != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 { |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
576 // 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
|
577 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
|
578 return OK; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 } |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
580 return FAIL; |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
581 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
583 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
|
584 import->imp_sid, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
585 idx, |
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
586 type); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28813
diff
changeset
|
590 // 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
|
591 // 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
|
592 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
|
593 &t_any); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 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
|
597 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
|
598 { |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
599 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
|
600 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
|
601 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
602 // 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
|
603 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
|
604 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 // 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
|
607 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
|
608 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
|
609 && 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
|
610 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
|
611 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
|
612 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 * 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
|
616 * "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
|
617 * "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
|
618 * 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
|
619 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 compile_load( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 char_u *end_arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 int is_expr, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 int error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 type_T *type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 char_u *name = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 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
|
631 int res = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 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
|
633 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 if (*(*arg + 1) == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 if (end <= *arg + 2) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 isntype_T isn_type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 // load dictionary of namespace |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 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
|
644 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
|
645 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
|
646 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
|
647 default: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 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
|
649 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 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
|
652 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 res = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 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
|
658 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 // load namespaced variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 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
|
661 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 return FAIL; |
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 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 { |
28992
0e9642706a59
patch 8.2.5018: Vim9: some code is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28968
diff
changeset
|
666 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
|
667 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
|
668 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
|
669 { |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27698
diff
changeset
|
670 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
|
671 *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
|
672 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
|
673 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
|
674 } |
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
|
675 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
|
676 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
|
677 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 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
|
679 NULL, &end); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 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
|
682 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 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
|
684 && 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
|
685 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
|
686 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 isn_type = ISN_LOADG; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 isn_type = ISN_LOADAUTO; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 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
|
694 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 goto theend; |
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 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
|
706 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 // 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
|
708 // 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
|
709 // 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
|
710 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
|
711 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 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
|
717 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 int gen_load = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 int gen_load_outer = 0; |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
720 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
|
721 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
|
722 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 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
|
724 if (name == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 |
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
|
727 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
|
728 && 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
|
729 && (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
|
730 { |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
731 // 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
|
732 // 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
|
733 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
|
734 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
|
735 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
|
736 } |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31663
diff
changeset
|
737 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
|
738 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 script_autoload(name, FALSE); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 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
|
741 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 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
|
743 == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 if (gen_load_outer == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 gen_load = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 { |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
750 lvar_T lvar; |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
751 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
|
752 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 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
|
754 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 type = lvar.lv_type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 idx = lvar.lv_idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 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
|
758 { |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 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
|
760 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
|
761 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
|
762 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 gen_load = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 } |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
766 else if ((idx = cctx_class_member_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
|
767 { |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
768 // Referencing a class variable without the class name. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
769 // A class variable can be referenced without the class name |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
770 // only in 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
|
771 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
|
772 res = generate_CLASSMEMBER(cctx, TRUE, cl, idx); |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
773 else |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
774 { |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
775 semsg(_(e_class_member_str_accessible_only_inside_class_str), |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
776 name, cl->class_name); |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
777 res = FAIL; |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
778 } |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31551
diff
changeset
|
779 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 // "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
|
783 // 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
|
784 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
|
785 || 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
|
786 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
|
787 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 // 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
|
789 // 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
|
790 // 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
|
791 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
|
792 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
|
793 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 if (gen_load) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 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
|
797 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
|
798 { |
30337
dac4fe437840
patch 9.0.0504: still a build failure
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 } |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 *arg = end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 theend: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 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
|
809 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
|
810 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 return res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 * 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
|
816 * "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
|
817 * 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
|
818 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 static int |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
820 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
|
821 { |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
822 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
|
823 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
|
824 int expr_res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 int trailing_error; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 int instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 isn_T *instr = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 // 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
|
830 --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
|
831 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 // 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
|
833 // correct. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 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
|
835 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
|
836 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
|
837 |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
838 // 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
|
839 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
|
840 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
|
841 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 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
|
843 |
2f8a3cde553f
patch 9.0.1164: evaluating string expression advances function line
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
844 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
|
845 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 s = skipwhite(s); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 trailing_error = *s != NUL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 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
|
850 || 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
|
851 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 if (trailing_error) |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
853 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
|
854 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
|
855 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
|
856 ++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
|
857 return FAIL; |
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 // 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
|
861 // 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
|
862 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
|
863 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
|
864 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
|
865 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 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
|
867 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
|
868 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
|
869 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
|
870 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 * Compile the argument expressions. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 * "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
|
876 */ |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
29782
diff
changeset
|
877 int |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
878 compile_arguments( |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
879 char_u **arg, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
880 cctx_T *cctx, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
881 int *argcount, |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
882 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
|
883 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 char_u *p = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 char_u *whitep = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 int must_end = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 int instr_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 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
|
892 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 if (*p == ')') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 *arg = p + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 if (must_end) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 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
|
901 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 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
|
905 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
|
906 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 ++*argcount; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
909 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
|
910 && 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
|
911 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 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
|
913 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 // {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
|
915 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
|
916 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
|
917 } |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
918 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
|
919 && 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
|
920 { |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
921 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
|
922 |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
923 // {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
|
924 // with \= |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
925 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
|
926 && 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
|
927 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
|
928 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 if (*p != ',' && *skipwhite(p) == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 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
|
933 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 if (*p == ',') |
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 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 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
|
939 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
|
940 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 must_end = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 whitep = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 failret: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 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
|
948 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 * 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
|
953 * "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
|
954 * "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
|
955 * Instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 * EVAL arg1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 * EVAL arg2 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 * BCALL / DCALL / UCALL |
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 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 compile_call( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 size_t varlen, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 ppconst_T *ppconst, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 int argcount_init) |
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 char_u *name = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 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
|
971 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
|
972 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
|
973 char_u *tofree = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 ufunc_T *ufunc = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 int res = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 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
|
977 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
|
978 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
|
979 imported_T *import; |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32088
diff
changeset
|
980 type_T *type; |
27235
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
981 |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
982 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
|
983 { |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
984 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
|
985 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
|
986 } |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
987 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
|
988 |
27698
3813036f19cb
patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents:
27613
diff
changeset
|
989 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
|
990 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
|
991 { |
6b80d4acac8e
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
992 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
|
993 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
|
994 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 // 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
|
997 // 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
|
998 // 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
|
999 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
|
1000 && (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
|
1001 || (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
|
1002 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 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
|
1004 typval_T argvars[2]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 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
|
1006 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
|
1007 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 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
|
1009 if (*s == '"') |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1010 (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
|
1011 else if (*s == '\'') |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1012 (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
|
1013 s = skipwhite(s); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 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
|
1015 && ((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
|
1016 || !is_has)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 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
|
1019 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 *arg = s + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 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
|
1022 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
|
1023 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
|
1024 if (is_has) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 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
|
1026 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
|
1027 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
|
1028 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 f_exists(argvars, tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 clear_tv(&argvars[0]); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 ++ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 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
|
1035 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
|
1036 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 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
|
1038 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 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
|
1043 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 |
31982
9113d903a2c6
patch 9.0.1323: build failure with +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1045 funcerror_T error; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 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
|
1047 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 // 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
|
1049 // differently. |
28692
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1050 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
|
1051 || (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
|
1052 || (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
|
1053 || (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
|
1054 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
|
1055 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
|
1056 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
|
1057 else |
bfd8e25fa207
patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
28598
diff
changeset
|
1058 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
|
1059 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 *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
|
1061 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
|
1062 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32088
diff
changeset
|
1064 type = get_decl_type_on_stack(cctx, 1); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 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
|
1066 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
|
1067 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 int idx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 // builtin function |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 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
|
1072 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 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
|
1075 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 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
|
1077 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 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
|
1081 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 // 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
|
1083 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
|
1084 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 // 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
|
1086 res = generate_LISTAPPEND(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 idx = -1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 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
|
1090 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 // 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
|
1092 res = generate_BLOBAPPEND(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 idx = -1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 |
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
|
1097 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
|
1098 || (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
|
1099 { |
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
|
1100 // 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
|
1101 // 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
|
1102 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
|
1103 idx = -1; |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1104 } |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
1105 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 if (idx >= 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 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
|
1108 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 else |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1110 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
|
1111 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1114 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
|
1115 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 // 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
|
1117 // overrules a function name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 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
|
1119 && 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
|
1120 { |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1121 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
|
1122 int mi = 0; |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1123 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 // 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
|
1125 // 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
|
1126 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
|
1127 if (ufunc != NULL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 { |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1129 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
|
1130 { |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32088
diff
changeset
|
1131 res = generate_CALL(cctx, ufunc, NULL, 0, type, argcount); |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1132 goto theend; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1133 } |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1134 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
|
1135 && 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
|
1136 { |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1137 // 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
|
1138 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
|
1139 goto theend; |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27376
diff
changeset
|
1140 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 } |
33233
108d890d887f
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1142 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
|
1143 { |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1144 // 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
|
1145 // 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
|
1146 // 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
|
1147 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
|
1148 { |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1149 res = generate_CALL(cctx, cl->class_class_functions[mi], NULL, |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1150 0, type, argcount); |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1151 } |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1152 else |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1153 { |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1154 semsg(_(e_class_member_str_accessible_only_inside_class_str), |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1155 name, cl->class_name); |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1156 res = FAIL; |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33246
diff
changeset
|
1157 } |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1158 goto theend; |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
1159 } |
26662
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 // 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
|
1163 // 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
|
1164 // 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
|
1165 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
|
1166 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
|
1167 && 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
|
1168 { |
32840
a8561f9b47aa
patch 9.0.1732: vimexpr: shadowing variable
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1169 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
|
1170 |
a8561f9b47aa
patch 9.0.1732: vimexpr: shadowing variable
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1171 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
|
1172 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 // 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
|
1176 if (ufunc != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 { |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32088
diff
changeset
|
1178 res = generate_CALL(cctx, ufunc, NULL, 0, type, argcount); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 goto theend; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 // 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
|
1183 // 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
|
1184 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
|
1185 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
|
1186 else |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28261
diff
changeset
|
1187 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
|
1188 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 theend: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 vim_free(tofree); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 return res; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 // 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
|
1195 #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
|
1196 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 * 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
|
1199 * 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
|
1200 * 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
|
1201 * 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
|
1202 * valid name. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 char_u * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 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
|
1206 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 // 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
|
1210 if (!eval_isnamec1(*arg)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 return arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 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
|
1214 // 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
|
1215 // 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
|
1216 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
|
1217 || !use_namespace |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 || 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
|
1219 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 return p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 * 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
|
1225 * 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
|
1226 * 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
|
1227 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 char_u * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 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
|
1230 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 char_u *p = arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 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
|
1235 p = skipdigits(p + 5); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 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
|
1237 if (p == arg && *arg == '[') |
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 // 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
|
1241 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
|
1242 p = arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 return p; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 * 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
|
1249 * "*arg" points to the '['. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 * 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
|
1251 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 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
|
1254 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 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
|
1256 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
|
1257 int count = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 int is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 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
|
1260 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
|
1261 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 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
|
1265 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26769
diff
changeset
|
1266 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
|
1267 return FAIL; |
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 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 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
|
1272 return FAIL; |
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 if (*p == ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 } |
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
|
1279 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
|
1280 { |
35cbea786334
patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
29759
diff
changeset
|
1281 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
|
1282 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
|
1283 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 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
|
1285 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 if (!is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 is_all_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 ++count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 if (*p == ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 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
|
1293 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 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
|
1295 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 } |
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
|
1298 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
|
1299 must_end = TRUE; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 whitep = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 p = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 *arg = p; |
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 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
|
1306 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
|
1307 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 * 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
|
1311 * "*arg" points to the '('. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 * 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
|
1313 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 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
|
1316 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 ufunc_T *ufunc; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 evalarg_T evalarg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 init_evalarg(&evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 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
|
1324 evalarg.eval_cctx = cctx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 // 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
|
1327 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
|
1328 if (r != OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 return r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 // "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
|
1335 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
|
1336 ++ufunc->uf_refcount; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 clear_tv(&rettv); |
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 // 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
|
1340 // 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
|
1341 // compile_return(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 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
|
1343 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
|
1344 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
|
1345 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 // 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
|
1347 // 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
|
1348 // the right context. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 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
|
1350 #ifdef FEAT_PROFILE |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 || 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
|
1352 #endif |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 ) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 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
|
1355 |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1356 // 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
|
1357 // one might be |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1358 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
|
1359 { |
28101
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1360 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
|
1361 |
3bc0a639dfb0
patch 8.2.4575: Vim9: test for profiling still fails
Bram Moolenaar <Bram@vim.org>
parents:
28097
diff
changeset
|
1362 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
|
1363 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
|
1364 } |
632a84e2ce92
patch 8.2.4573: a nested function is compiled for debugging without context
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
1365 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 // 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
|
1367 // "*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
|
1368 // dangling pointer. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 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
|
1370 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 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
|
1372 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
|
1373 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 *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
|
1375 + off; |
30437
d77a900f6094
patch 9.0.0554: using freed memory when command follows lambda
Bram Moolenaar <Bram@vim.org>
parents:
30337
diff
changeset
|
1376 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
|
1377 } |
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 clear_evalarg(&evalarg, NULL); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 if (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
|
1382 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 // 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
|
1384 set_function_type(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 // 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
|
1387 // 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
|
1388 // function is freed. |
31920
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
1389 return generate_FUNCREF(cctx, ufunc, NULL, 0, NULL); |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 func_ptr_unref(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 * 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
|
1398 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 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
|
1401 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 typval_T *rettv, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 int types_optional, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 evalarg_T *evalarg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 int r; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 ufunc_T *ufunc; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 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
|
1409 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 // 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
|
1411 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
|
1412 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
|
1413 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
|
1414 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
|
1415 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
|
1416 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 // "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
|
1418 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
|
1419 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 // 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
|
1421 // 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
|
1422 // compile_return(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 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
|
1424 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
|
1425 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
|
1426 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 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
|
1428 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 // 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
|
1430 set_function_type(ufunc); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 * 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
|
1439 * "*arg" points to the '{'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 * 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
|
1441 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 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
|
1444 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 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
|
1446 int count = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 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
|
1448 dictitem_T *item; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 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
|
1450 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 int is_const; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 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
|
1453 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 if (d == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 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
|
1457 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 for (;;) |
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 char_u *key = NULL; |
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 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
|
1463 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 if (**arg == '}') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 break; |
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 if (**arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 isn_T *isn; |
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 // {[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
|
1476 *arg = skipwhite(*arg + 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 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
|
1478 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 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
|
1480 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
|
1481 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 char buf[NUMBUFLEN]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 // 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
|
1485 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
|
1486 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
|
1487 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
|
1488 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 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
|
1490 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
|
1491 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
|
1492 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 if (**arg != ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 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
|
1497 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 ++*arg; |
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 else |
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 // {"name": value}, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 // {'name': value}, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 // {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
|
1506 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
|
1507 if (key == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 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
|
1510 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 // 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
|
1514 if (key != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 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
|
1517 if (item != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1519 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
|
1520 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 item = dictitem_alloc(key); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 if (item != NULL) |
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 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
|
1526 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
|
1527 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
|
1528 dictitem_free(item); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 } |
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 if (**arg != ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 if (*skipwhite(*arg) == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 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
|
1536 else |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1537 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
|
1538 return FAIL; |
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 whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 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
|
1542 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 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
|
1544 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 } |
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 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
|
1548 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 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
|
1554 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 if (!is_const) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 is_all_const = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 ++count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 whitep = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 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
|
1561 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 *arg = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 if (**arg == '}') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 if (**arg != ',') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1569 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
|
1570 goto failret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 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
|
1573 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 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
|
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 whitep = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 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
|
1579 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 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
|
1581 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 *arg = skipwhite(whitep); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 *arg = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 // 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
|
1589 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 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
|
1591 *arg += STRLEN(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 dict_unref(d); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 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
|
1595 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
|
1596 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1597 failret: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 if (*arg == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 { |
31602
53c3df37a2b0
patch 9.0.1133: error message names do not match the items
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
1600 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
|
1601 *arg = (char_u *)""; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1602 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 dict_unref(d); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 |
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 * Compile "&option". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 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
|
1612 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 typval_T rettv; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 char_u *start = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 int ret; |
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 // 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
|
1618 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
|
1619 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
|
1620 if (ret == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 // 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
|
1623 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
|
1624 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
|
1625 : 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
|
1626 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 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
|
1628 vim_free(name); |
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 clear_tv(&rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 * Compile "$VAR". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 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
|
1640 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 char_u *start = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 int len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 char_u *name; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 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
|
1648 if (len == 0) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 { |
27041
fc19375787dd
patch 8.2.4049: Vim9: reading before the start of the line with "$"
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
1650 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
|
1651 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 // 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
|
1655 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
|
1656 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
|
1657 vim_free(name); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 /* |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1662 * 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
|
1663 */ |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1664 static int |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1665 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
|
1666 { |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1667 typval_T tv; |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1668 int ret; |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1669 int quote; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1670 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
|
1671 int count = 0; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1672 char_u *p; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1673 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1674 // *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
|
1675 ++*arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1676 quote = **arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1677 ++*arg; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1678 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1679 for (;;) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1680 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1681 // 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
|
1682 // "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
|
1683 if (quote == '"') |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1684 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
|
1685 else |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1686 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
|
1687 if (ret == FAIL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1688 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1689 if (evaluate) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1690 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1691 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
|
1692 || (**arg != '{' && count == 0)) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1693 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1694 // 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
|
1695 // one |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1696 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
|
1697 return FAIL; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1698 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
|
1699 ++count; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1700 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1701 clear_tv(&tv); |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1702 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1703 |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1704 if (**arg != '{') |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1705 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1706 // found terminating quote |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1707 ++*arg; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1708 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1709 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1710 |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1711 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
|
1712 if (p == NULL) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1713 { |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1714 ret = FAIL; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1715 break; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1716 } |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1717 ++count; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1718 *arg = p; |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1719 } |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1720 |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1721 if (ret == FAIL || !evaluate) |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1722 return ret; |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1723 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1724 // 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
|
1725 if (count > 1) |
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1726 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
|
1727 |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
1728 return OK; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1729 } |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1730 |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
1731 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 * Compile "@r". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 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
|
1736 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 if (**arg == NUL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 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
|
1743 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 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
|
1746 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 emsg_invreg(**arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 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
|
1751 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1754 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1755 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 * 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
|
1757 * 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
|
1758 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 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
|
1761 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 char_u *p = *end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 // 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
|
1765 while (p > start) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 if (*p == '-' || *p == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 // 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
|
1771 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
|
1772 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 if (*p == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 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
|
1775 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 varnumber_T val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 int error = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 // 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
|
1782 // here |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 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
|
1784 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 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
|
1786 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 if (error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 if (*p == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 val = -val; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 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
|
1792 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
|
1793 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 else if (numeric_only) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 else if (*p == '!') |
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 v = tv2bool(rettv); |
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 // '!' 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
|
1805 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 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
|
1807 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
|
1808 } |
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 *end = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 |
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 * 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
|
1816 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 static void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 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
|
1819 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 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
|
1821 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 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
|
1823 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
|
1824 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 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
|
1827 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1828 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
|
1829 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
|
1830 *arg += 7; |
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 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
|
1833 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 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
|
1835 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
|
1836 *arg += 6; |
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 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
|
1839 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 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
|
1841 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
|
1842 *arg += 6; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 exprtype_T |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1847 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
|
1848 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 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
|
1850 int i; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 switch (p[0]) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1853 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1854 case '=': if (p[1] == '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1855 type = EXPR_EQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 else if (p[1] == '~') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 type = EXPR_MATCH; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 case '!': if (p[1] == '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 type = EXPR_NEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 else if (p[1] == '~') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 type = EXPR_NOMATCH; |
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 case '>': if (p[1] != '=') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 type = EXPR_GREATER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 *len = 1; |
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 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 type = EXPR_GEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 case '<': if (p[1] != '=') |
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 type = EXPR_SMALLER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 *len = 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 type = EXPR_SEQUAL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 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
|
1881 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 // "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
|
1883 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
|
1884 *len = 5; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 i = p[*len]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 if (!isalnum(i) && i != '_') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1887 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1888 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
|
1889 *type_is = TRUE; |
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1893 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1894 return type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 * 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
|
1899 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 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
|
1902 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 evalarg_T evalarg; |
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 init_evalarg(&evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 evalarg.eval_cctx = cctx; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1907 skip_expr(arg, &evalarg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 clear_evalarg(&evalarg, NULL); |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 * 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
|
1913 * 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
|
1914 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 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
|
1917 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 type_T *type; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
1920 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
|
1921 if (type == &t_bool) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 |
30888
54ba95d2d2eb
patch 9.0.0778: indexing of unknown const type fails during compilation
Bram Moolenaar <Bram@vim.org>
parents:
30437
diff
changeset
|
1924 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
|
1925 || 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
|
1926 || 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
|
1927 || 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
|
1928 || 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
|
1929 // 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
|
1930 // 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
|
1931 return generate_COND2BOOL(cctx); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 |
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
|
1933 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
|
1934 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 * 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
|
1938 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 void |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 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
|
1941 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 char_u buf[10]; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 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
|
1945 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
|
1946 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1948 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 * 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
|
1950 * 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
|
1951 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1952 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 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
|
1954 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 char_u *p = *end; |
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 // 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
|
1958 while (p > start) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 while (VIM_ISWHITE(*p)) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 if (*p == '-' || *p == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 { |
31549
6f1cbee3d652
patch 9.0.1107: float constant not recognized as float
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
1965 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
|
1966 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
|
1967 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
|
1968 return FAIL; |
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 // 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
|
1971 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
|
1972 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 else if (numeric_only) |
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 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 int invert = *p == '!'; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 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
|
1984 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 if (p[-1] == '!') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 invert = !invert; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 --p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 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
|
1990 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1991 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1993 *end = p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1994 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 * Compile "(expression)": recursive! |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1999 * Return FAIL/OK. |
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 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 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
|
2003 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 int ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 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
|
2006 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 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
|
2008 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2009 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
|
2010 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2011 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
|
2012 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2013 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2015 // 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
|
2016 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
|
2017 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 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
|
2019 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 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
|
2021 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 if (**arg == ')') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 else if (ret == OK) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 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
|
2027 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2032 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
|
2033 |
26662
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 * 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
|
2036 * 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
|
2037 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2039 compile_subscript( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2041 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 char_u *start_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 char_u **end_leader, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2044 ppconst_T *ppconst) |
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 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
|
2047 int keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2048 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2049 for (;;) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2051 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
|
2052 type_T *type; |
26662
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 (*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
|
2055 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2056 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
|
2057 |
30930
cbfbf0e17cd0
patch 9.0.0799: in compiled function ->() on next line not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30888
diff
changeset
|
2058 // 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
|
2059 // 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
|
2060 // 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
|
2061 if (next != NULL && |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2062 ((next[0] == '-' && next[1] == '>' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2063 && (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
|
2064 || next[2] == '(' |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2065 || 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
|
2066 || (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
|
2067 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2068 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
|
2069 if (next == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2070 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2071 *arg = next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2073 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 } |
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 // 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
|
2077 // 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
|
2078 if (**arg == '(') |
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 int argcount = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2082 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
|
2083 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 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
|
2085 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2086 // 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
|
2087 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
|
2088 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 *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
|
2090 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
|
2091 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 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
|
2093 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 if (keeping_dict) |
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 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2097 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
|
2098 return FAIL; |
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2101 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
|
2102 { |
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
|
2103 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
|
2104 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
|
2105 char_u *paren; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2106 |
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
|
2107 // something->method() |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2108 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
|
2109 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 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
|
2111 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2112 // Apply the '!', '-' and '+' first: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 // -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
|
2114 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
|
2115 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 p += 2; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 *arg = skipwhite(p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2119 // 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
|
2120 |
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
|
2121 // 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
|
2122 // 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
|
2123 // 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
|
2124 // 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
|
2125 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
|
2126 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
|
2127 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
|
2128 { |
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
|
2129 // 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
|
2130 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
|
2131 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
|
2132 { |
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
|
2133 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
|
2134 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
|
2135 } |
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
|
2136 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
|
2137 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
|
2138 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
|
2139 ; |
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
|
2140 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
|
2141 { |
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
|
2142 // 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
|
2143 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
|
2144 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
|
2145 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
|
2146 } |
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
|
2147 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
|
2148 { |
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
|
2149 // 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
|
2150 // 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
|
2151 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
|
2152 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
|
2153 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
|
2154 { |
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
|
2155 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
|
2156 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
|
2157 } |
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
|
2158 } |
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
|
2159 } |
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
|
2160 |
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
|
2161 if (alt != 1) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2162 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2163 int argcount = 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 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
|
2165 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
|
2166 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
|
2167 int expr_isn_end; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 int arg_isn_count; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2169 |
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
|
2170 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
|
2171 { |
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 // 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
|
2173 // 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
|
2174 // |
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
|
2175 // 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
|
2176 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
|
2177 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
|
2178 } |
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
|
2179 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
|
2180 { |
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
|
2181 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
|
2182 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
|
2183 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
|
2184 |
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 *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
|
2186 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
2187 // 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
|
2188 ++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
|
2189 |
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
|
2190 // 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
|
2191 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
|
2192 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2193 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
|
2194 || *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
|
2195 *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
|
2196 --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
|
2197 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
|
2198 |
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
|
2199 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
|
2200 { |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
2201 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
|
2202 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
|
2203 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
|
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 } |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 // Compile the arguments. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 if (**arg != '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2210 if (*skipwhite(*arg) == '(') |
26887
612339679616
patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
2211 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
|
2212 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2213 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
|
2214 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2215 } |
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
|
2216 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
2217 // 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
|
2218 // 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
|
2219 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
|
2220 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 *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
|
2222 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
|
2223 == FAIL) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 // 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
|
2227 // 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
|
2228 // 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
|
2229 // expects. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2230 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
|
2231 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
|
2232 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 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
|
2234 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
|
2235 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
|
2236 type2_T *typep; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2238 if (isn == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2239 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2240 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
|
2241 + expr_isn_start, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2242 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
|
2243 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
|
2244 + expr_isn_start, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 ((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
|
2246 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
|
2247 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
|
2248 + 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
|
2249 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
|
2250 vim_free(isn); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2252 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
|
2253 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
|
2254 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
|
2255 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
|
2256 ((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
|
2257 sizeof(type2_T) |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2258 * (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
|
2259 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
|
2260 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
|
2261 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
|
2262 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2263 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
2264 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
|
2265 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
|
2266 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2267 } |
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 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2269 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2270 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2272 if (generate_instr(cctx, ISN_CLEARDICT) == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2274 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2275 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2276 else if (**arg == '[') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2277 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2278 int is_slice = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2279 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2280 // list index: list[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2281 // dict member: dict[key] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2282 // string index: text[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2283 // blob index: blob[123] |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2284 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
|
2285 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2286 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
|
2287 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2288 ++p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2289 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
|
2290 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2291 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2292 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2293 // 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
|
2294 generate_PUSHNR(cctx, 0); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2295 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2296 else |
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 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
|
2299 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2300 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2301 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2302 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
|
2303 ":", *arg); |
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 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2306 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
|
2307 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2308 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2309 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2310 if (**arg == ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2311 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2312 is_slice = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2313 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2314 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
|
2315 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2316 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
|
2317 ":", *arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2318 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2319 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2320 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
|
2321 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2322 if (**arg == ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2323 // 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
|
2324 generate_PUSHNR(cctx, -1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2325 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2326 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2327 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
|
2328 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2329 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
|
2330 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2331 *arg = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2333 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2334 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2335 if (**arg != ']') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2336 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2337 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
|
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 *arg = *arg + 1; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2341 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2342 if (keeping_dict) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2343 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2344 keeping_dict = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2345 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
|
2346 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2347 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2348 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
|
2349 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 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
|
2352 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 // dictionary member: dict.name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 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
|
2355 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 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
|
2357 |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2358 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
|
2359 && (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
|
2360 || 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
|
2361 { |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2362 // 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
|
2363 // 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
|
2364 // 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
|
2365 // 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
|
2366 // 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
|
2367 *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
|
2368 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
|
2369 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2370 } |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2371 else |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 { |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2373 *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
|
2374 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
|
2375 { |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2376 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
|
2377 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
|
2378 } |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2379 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
|
2380 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
|
2381 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
|
2382 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
|
2383 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
|
2384 { |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2385 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
|
2386 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
|
2387 } |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
2388 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
|
2389 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
|
2390 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
|
2391 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
|
2392 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
|
2393 *arg = p; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2394 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2395 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2396 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 break; |
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 // 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
|
2401 // 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
|
2402 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
|
2403 && 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
|
2404 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2405 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 * 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
|
2411 * "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
|
2412 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2413 * 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
|
2414 * 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
|
2415 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 * 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
|
2417 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2418 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2419 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2420 * number number constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2421 * 0zFFFFFFFF Blob constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2422 * "string" string constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2423 * 'string' literal string constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2424 * &option-name option value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 * @r register contents |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2426 * identifier variable value |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2427 * function() function call |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2428 * $VAR environment variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2429 * (expression) nested expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2430 * [expr, expr] List |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2431 * {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
|
2432 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2433 * Also handle: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2434 * ! in front logical NOT |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2435 * - in front unary minus |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2436 * + 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
|
2437 * 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
|
2438 * 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
|
2439 * 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
|
2440 * trailing ->name() method call |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2441 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2442 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2443 compile_expr9( |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2444 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2445 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2446 ppconst_T *ppconst) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2447 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2448 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
|
2449 int ret = OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2450 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
|
2451 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
|
2452 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2453 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
|
2454 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2455 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2456 * 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
|
2457 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2458 start_leader = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2459 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
|
2460 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 end_leader = *arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2463 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
|
2464 switch (**arg) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2466 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2467 * Number constant. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2468 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2469 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
|
2470 case '1': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2471 case '2': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2472 case '3': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2473 case '4': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2474 case '5': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2475 case '6': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2476 case '7': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2477 case '8': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2478 case '9': |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2479 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
|
2480 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2481 // 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
|
2482 // 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
|
2483 // '!'. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2484 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
|
2485 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
|
2486 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2487 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2488 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2489 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2490 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2491 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2492 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2493 * String constant: "string". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2494 */ |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
2495 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
|
2496 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2497 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2498 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2499 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2500 * 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
|
2501 */ |
28813
3626ca6a20ea
patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents:
28718
diff
changeset
|
2502 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
|
2503 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2504 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2505 |
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 * Constant Vim variable. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2508 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2509 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
|
2510 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2511 break; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2514 * "true" constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2515 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2516 case '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
|
2517 && !eval_isnamec((*arg)[4])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2518 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2519 *arg += 4; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2520 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
|
2521 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
|
2522 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2523 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2524 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2525 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2526 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2527 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2528 * "false" constant |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2529 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2530 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
|
2531 && !eval_isnamec((*arg)[5])) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2532 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2533 *arg += 5; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2534 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
|
2535 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
|
2536 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2537 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2538 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2539 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2540 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2541 /* |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2542 * "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
|
2543 */ |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2544 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
|
2545 { |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2546 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
|
2547 int len; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2548 |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2549 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
|
2550 ; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2551 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
|
2552 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
|
2553 ret = NOTDONE; |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2554 else |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
2555 *arg += len + 4; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2556 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2557 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2558 ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2559 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2560 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2561 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2562 * List: [expr, expr] |
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 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
|
2565 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2566 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
|
2567 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2568 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2569 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2570 * 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
|
2571 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2572 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
|
2573 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2574 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
|
2575 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2576 |
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 * Option value: &name |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2579 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2580 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
|
2581 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2582 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
|
2583 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2584 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2585 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2586 * Environment variable: $VAR. |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2587 * 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
|
2588 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2589 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
|
2590 return FAIL; |
28718
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2591 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
|
2592 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
|
2593 else |
723c7d940cba
patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28692
diff
changeset
|
2594 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
|
2595 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2596 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2597 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2598 * Register contents: @r. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2599 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2600 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
|
2601 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2602 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
|
2603 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2604 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2605 * nested expression: (expression). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 * lambda: (arg, arg) => expr |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2607 * funcref: (arg, arg) => { statement } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2608 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2609 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
|
2610 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
|
2611 if (ret == NOTDONE) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2612 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
|
2613 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2614 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2615 default: ret = NOTDONE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2616 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2617 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 if (ret == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2619 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2620 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 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
|
2622 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 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
|
2624 clear_tv(rettv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2626 // 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
|
2627 // 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
|
2628 ++ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 else if (ret == NOTDONE) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2632 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 int r; |
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 if (!eval_isnamec1(**arg)) |
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 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
|
2638 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 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
|
2640 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
|
2641 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2642 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
|
2643 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2644 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2646 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 // "name" or "name()" |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2648 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
|
2649 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
|
2650 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 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
|
2652 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 if (*p == '(') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2656 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2657 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
|
2658 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2659 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2660 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 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
|
2662 && 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
|
2663 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 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
|
2665 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 if (r == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 } |
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 // Handle following "[]", ".member", etc. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2671 // 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
|
2672 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
|
2673 ppconst) == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 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
|
2676 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 // 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
|
2678 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
|
2679 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
|
2680 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 return OK; |
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 (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
|
2684 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2686 } |
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 /* |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2689 * <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
|
2690 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2692 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
|
2693 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 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
|
2695 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 // Recognize <type> |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2697 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
|
2698 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2700 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
|
2701 if (want_type == NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 return FAIL; |
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 (**arg != '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 if (*skipwhite(*arg) == '>') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 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
|
2708 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 emsg(_(e_missing_gt)); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2710 return FAIL; |
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 ++*arg; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 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
|
2714 return FAIL; |
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 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2717 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
|
2718 return FAIL; |
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 (want_type != NULL) |
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 type_T *actual; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 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
|
2724 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 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
|
2726 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
|
2727 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
|
2728 { |
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
|
2729 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
|
2730 -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
|
2731 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2732 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 } |
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 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2737 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2738 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2739 * * number multiplication |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2740 * / number division |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2741 * % number modulo |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2743 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2744 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
|
2745 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2746 char_u *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2747 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2748 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
|
2749 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2750 // get the first expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2751 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
|
2752 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2753 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2754 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2755 * 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
|
2756 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2757 for (;;) |
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 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
|
2760 if (*op != '*' && *op != '/' && *op != '%') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 if (next != NULL) |
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 = 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
|
2765 op = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2766 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2767 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 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
|
2769 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 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
|
2771 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2773 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
|
2774 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2776 // get the second expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2777 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
|
2778 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2779 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2780 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
|
2781 && 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
|
2782 && 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
|
2783 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2784 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
|
2785 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
|
2786 varnumber_T res = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2787 int failed = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2788 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2789 // 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
|
2790 switch (*op) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2791 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2792 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
|
2793 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2794 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
|
2795 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
|
2796 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2797 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
|
2798 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
|
2799 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2801 if (failed) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2802 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2803 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
|
2804 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2805 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 else |
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 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2809 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
|
2810 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2812 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2813 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2816 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2817 * + 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
|
2818 * - number subtraction |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2819 * .. string concatenation |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2820 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2821 static int |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2822 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
|
2823 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2824 char_u *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2825 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2826 int oplen; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 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
|
2828 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2829 // get the first variable |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2830 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
|
2831 return FAIL; |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2834 * 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
|
2835 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2836 for (;;) |
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 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
|
2839 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
|
2840 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2841 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
|
2842 // 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
|
2843 // But ".." is concatenation. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2844 break; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2845 oplen = (*op == '.' ? 2 : 1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2846 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2847 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2848 *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
|
2849 op = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2850 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2851 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2852 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
|
2853 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2854 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
|
2855 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2858 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
|
2859 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2860 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2861 // get the second expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2862 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
|
2863 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2864 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2865 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
|
2866 && (*op == '.' |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2867 ? (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
|
2868 && 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
|
2869 : (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
|
2870 && 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
|
2871 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2872 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
|
2873 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
|
2874 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2875 // 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
|
2876 if (*op == '+') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2877 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
|
2878 else if (*op == '-') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2879 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
|
2880 else |
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 // concatenate constant strings |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2883 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
|
2884 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
|
2885 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
|
2886 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2887 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
|
2888 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
|
2889 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2890 clear_ppconst(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2891 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2892 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2893 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
|
2894 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
|
2895 vim_free(s1); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2896 vim_free(s2); |
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 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2899 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2900 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2901 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2902 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2903 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
|
2904 if (*op == '.') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2905 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2906 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
|
2907 || 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
|
2908 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
|
2909 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
|
2910 return FAIL; |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2911 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2912 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2913 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
|
2914 } |
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 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2920 /* |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2921 * expr6a >> expr6b |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2922 * expr6a << expr6b |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2923 * |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2924 * Produces instructions: |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2925 * OPNR bitwise left or right shift |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2926 */ |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2927 static int |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2928 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
|
2929 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2930 exprtype_T type = EXPR_UNKNOWN; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2931 char_u *p; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2932 char_u *next; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2933 int len = 2; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2934 int ppconst_used = ppconst->pp_used; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2935 isn_T *isn; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2936 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2937 // get the first variable |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2938 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
|
2939 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2940 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2941 /* |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2942 * 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
|
2943 */ |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2944 for (;;) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2945 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2946 type = EXPR_UNKNOWN; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2947 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2948 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
|
2949 if (p[0] == '<' && p[1] == '<') |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2950 type = EXPR_LSHIFT; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2951 else if (p[0] == '>' && p[1] == '>') |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2952 type = EXPR_RSHIFT; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2953 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2954 if (type == EXPR_UNKNOWN) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2955 return OK; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2956 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2957 // 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
|
2958 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
|
2959 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
2960 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
|
2961 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2962 // left operand should be a number |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2963 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
|
2964 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2965 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2966 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2967 else |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2968 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2969 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
|
2970 |
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
|
2971 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
|
2972 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2973 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
|
2974 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2975 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2976 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2977 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2978 if (next != NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2979 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2980 *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
|
2981 p = skipwhite(*arg); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2982 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2983 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2984 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
|
2985 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2986 error_white_both(p, len); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2987 return FAIL; |
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 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2990 // get the second variable |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2991 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
|
2992 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2993 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2994 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
|
2995 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2996 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2997 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
|
2998 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
2999 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
|
3000 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
|
3001 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3002 // 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
|
3003 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
|
3004 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3005 // 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
|
3006 if (tv2->v_type != VAR_NUMBER) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3007 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
|
3008 else |
30986
360f286b5869
patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents:
30930
diff
changeset
|
3009 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
|
3010 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3011 } |
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 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
|
3014 tv1->vval.v_number = 0; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3015 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
|
3016 tv1->vval.v_number = |
3043a3e2ef95
patch 8.2.5006: asan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
28966
diff
changeset
|
3017 (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
|
3018 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
|
3019 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
|
3020 (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
|
3021 clear_tv(tv2); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3022 --ppconst->pp_used; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3023 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3024 else |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3025 { |
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
|
3026 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
|
3027 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
|
3028 { |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3029 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
|
3030 return FAIL; |
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 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3033 generate_ppconst(cctx, ppconst); |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3034 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3035 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
|
3036 if (isn == NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3037 return FAIL; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3038 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3039 if (isn != NULL) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3040 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
|
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 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3044 return OK; |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3045 } |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3046 |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3047 /* |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3048 * expr5a == expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3049 * expr5a =~ expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3050 * expr5a != expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3051 * expr5a !~ expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3052 * expr5a > expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3053 * expr5a >= expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3054 * expr5a < expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3055 * expr5a <= expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3056 * expr5a is expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3057 * expr5a isnot expr5b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3058 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3059 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3060 * 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
|
3061 * 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
|
3062 * 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
|
3063 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3064 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3065 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
|
3066 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3067 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
|
3068 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3069 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3070 int len = 2; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3071 int type_is = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3072 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
|
3073 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3074 // get the first variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3075 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
|
3076 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3077 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3078 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
|
3079 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3080 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
|
3081 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3082 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3083 * 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
|
3084 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3085 if (type != EXPR_UNKNOWN) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3086 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3087 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
|
3088 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3089 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3090 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3091 *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
|
3092 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3093 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3094 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
|
3095 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3096 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
|
3097 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3098 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3099 // 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
|
3100 if (p[len] == '?') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3101 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3102 ic = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3103 ++len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3104 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3105 // 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
|
3106 else if (p[len] == '#') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3107 ++len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3108 // nothing appended: match case |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3109 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3110 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
|
3111 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3112 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
|
3113 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3114 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3115 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3116 // get the second variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3117 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
|
3118 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3119 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3120 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
|
3121 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3122 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3123 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
|
3124 { |
28966
fc7070c42d23
patch 8.2.5005: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
28964
diff
changeset
|
3125 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
|
3126 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
|
3127 int ret; |
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 // 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
|
3130 // 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
|
3131 // strict than typval_compare(). |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3132 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
|
3133 ret = FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3135 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3136 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
|
3137 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
|
3138 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
|
3139 ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3140 clear_tv(tv2); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3141 --ppconst->pp_used; |
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 return ret; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3144 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3145 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3146 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3147 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
|
3148 } |
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 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3153 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
|
3154 |
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 * Compile || or &&. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3157 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3158 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3159 compile_and_or( |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3160 char_u **arg, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3161 cctx_T *cctx, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3162 char *op, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3163 ppconst_T *ppconst, |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3164 int ppconst_used UNUSED) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3165 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3166 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3167 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
|
3168 int opchar = *op; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3169 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3170 if (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
|
3171 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3172 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
|
3173 garray_T end_ga; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3174 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
|
3175 |
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 * 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
|
3178 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3179 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
|
3180 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
|
3181 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3182 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
|
3183 long save_sourcing_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3184 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
|
3185 int save_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3186 int const_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3187 int status; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3188 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
|
3189 ? 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
|
3190 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3191 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3192 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3193 *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
|
3194 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3195 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3196 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3197 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
|
3198 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3199 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
|
3200 op, p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3201 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3202 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3203 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3204 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3205 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
|
3206 SOURCING_LNUM = start_lnum; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3207 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
|
3208 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
|
3209 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3210 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
|
3211 if (status != FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3212 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3213 // 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
|
3214 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
|
3215 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3216 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
|
3217 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
|
3218 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3219 if ((is_true && opchar == '|') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3220 || (!is_true && opchar == '&')) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3221 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3222 // 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
|
3223 // 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
|
3224 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
|
3225 clear_tv(tv); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3226 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
|
3227 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
|
3228 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3229 else |
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 // 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
|
3232 // needs to be evaluated. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3233 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3234 jump_when = JUMP_NEVER; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3235 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3236 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3237 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3238 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3239 // 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
|
3240 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
|
3241 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3242 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3243 if (status != FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3244 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
|
3245 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
|
3246 if (status == FAIL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3247 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3248 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3249 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3250 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3251 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3252 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
|
3253 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3254 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
|
3255 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3256 *(((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
|
3257 ++end_ga.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3258 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3259 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
|
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 // eval the next expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3263 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
|
3264 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
|
3265 { |
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 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
|
3271 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
|
3272 : 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
|
3273 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3274 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3275 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3276 } |
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 // "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
|
3279 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
|
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3283 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
|
3284 && (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
|
3285 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3286 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
|
3287 ? VVAL_TRUE : VVAL_FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3288 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
|
3289 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3290 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3291 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3292 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
|
3293 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3294 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3295 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
|
3296 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3297 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3298 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3299 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3300 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3301 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
|
3302 // 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
|
3303 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
|
3304 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3305 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3306 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3307 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3308 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3309 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
|
3310 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3311 // 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
|
3312 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3313 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
|
3314 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3315 isn_T *isn; |
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 --end_ga.ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3318 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
|
3319 + *(((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
|
3320 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
|
3321 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3322 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3323 ga_clear(&end_ga); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3324 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3325 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
|
3326 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3327 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3328 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3329 } |
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 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3332 * 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
|
3333 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3334 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3335 * 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
|
3336 * 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
|
3337 * 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
|
3338 * 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
|
3339 * 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
|
3340 * 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
|
3341 * end: |
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 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3344 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
|
3345 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3346 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
|
3347 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3348 // get the first variable |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3349 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
|
3350 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3351 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3352 // || 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
|
3353 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
|
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 * 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
|
3358 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3359 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3360 * 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
|
3361 * 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
|
3362 * 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
|
3363 * 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
|
3364 * 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
|
3365 * 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
|
3366 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3367 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3368 static int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3369 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
|
3370 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 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
|
3372 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3373 // eval the first expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3374 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
|
3375 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3376 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3377 // || 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
|
3378 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
|
3379 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3380 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3381 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3382 * 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
|
3383 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3384 * 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
|
3385 * 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
|
3386 * EVAL expr1a |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3387 * JUMP_ALWAYS end |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3388 * alt: EVAL expr1b |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3389 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3390 * |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3391 * Toplevel expression: expr2 ?? expr1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3392 * Produces instructions: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3393 * 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
|
3394 * 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
|
3395 * EVAL expr1 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3396 * end: |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3397 */ |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3398 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3399 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
|
3400 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3401 char_u *p; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3402 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
|
3403 char_u *next; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3404 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3405 // 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
|
3406 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
|
3407 { |
27539
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27505
diff
changeset
|
3408 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
|
3409 |
26662
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3410 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
|
3411 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
|
3412 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3413 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3414 // Evaluate the first expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3415 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
|
3416 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3417 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3418 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
|
3419 if (*p == '?') |
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 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
|
3422 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
|
3423 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
|
3424 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
|
3425 int end_idx = 0; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3426 isn_T *isn; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3427 type_T *type1 = NULL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3428 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
|
3429 int const_value = FALSE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3430 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
|
3431 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3432 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3433 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3434 *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
|
3435 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3436 } |
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 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
|
3439 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3440 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
|
3441 op_falsy ? "??" : "?", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3442 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3443 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3444 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3445 if (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
|
3446 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3447 // 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
|
3448 // 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
|
3449 has_const_expr = TRUE; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3450 if (op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3451 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
|
3452 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3453 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3454 int error = FALSE; |
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 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
|
3457 &error); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3458 if (error) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3459 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3460 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3461 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
|
3462 (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
|
3463 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3464 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
|
3465 // "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
|
3466 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3467 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3468 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3469 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
|
3470 --ppconst->pp_used; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3471 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3472 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3473 else |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3474 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3475 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3476 if (op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3477 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
|
3478 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
|
3479 ? 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
|
3480 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
|
3481 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
|
3482 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3483 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3484 // 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
|
3485 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
|
3486 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3487 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
|
3488 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3489 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3490 if (!has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3491 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3492 generate_ppconst(cctx, ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3493 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3494 if (!op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3495 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3496 // 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
|
3497 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
|
3498 --stack->ga_len; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3499 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3500 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
|
3501 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
|
3502 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3503 // 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
|
3504 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
|
3505 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
|
3506 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3507 } |
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 if (!op_falsy) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3510 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3511 // Check for the ":". |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3512 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
|
3513 if (*p != ':') |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3514 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3515 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
|
3516 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3517 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3518 if (next != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3519 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3520 *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
|
3521 p = skipwhite(*arg); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3522 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3523 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3524 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
|
3525 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3526 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
|
3527 ":", p); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3528 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3529 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3530 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3531 // evaluate the third expression |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3532 if (has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3533 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
|
3534 ? SKIP_YES : SKIP_NOT; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3535 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
|
3536 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3537 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
|
3538 return FAIL; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3541 if (!has_const_expr) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3542 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3543 type_T **typep; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3544 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3545 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
|
3546 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
|
3547 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3548 // 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
|
3549 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
|
3550 + 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
|
3551 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
|
3552 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3553 // 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
|
3554 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
|
3555 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
|
3556 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3557 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3558 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
|
3559 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3560 return OK; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3561 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3562 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3563 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3564 * Toplevel expression. |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3565 * 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
|
3566 * Returns OK or FAIL. |
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 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3569 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
|
3570 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3571 ppconst_T ppconst; |
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 CLEAR_FIELD(ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3574 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
|
3575 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3576 clear_ppconst(&ppconst); |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3577 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3578 } |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3579 if (is_const != NULL) |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3580 *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
|
3581 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
|
3582 return FAIL; |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3583 return OK; |
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 |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3586 /* |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3587 * Toplevel expression. |
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 int |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3590 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
|
3591 { |
4b23672d1f0e
patch 8.2.3860: Vim9: codecov struggles with the file size
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3592 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
|
3593 } |
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 #endif // defined(FEAT_EVAL) |