Mercurial > vim
annotate src/vim9type.c @ 22517:6acf73cc1863
Added tag v8.2.1806 for changeset c174ec901f7e95d098321a535289f894455a2458
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 06 Oct 2020 20:00:05 +0200 |
parents | 4c21f7f6f9e3 |
children | af26fadf333d |
rev | line source |
---|---|
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * vim9type.c: handling of types |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #define USING_FLOAT_STUFF |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 #include "vim.h" |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 #if defined(FEAT_EVAL) || defined(PROTO) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 #ifdef VMS |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 # include <float.h> |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 #endif |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 * Allocate memory for a type_T and add the pointer to type_gap, so that it can |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
25 * be easily freed later. |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 */ |
22184
2463b3d89ce2
patch 8.2.1641: Vim9: cannot use 0 or 1 where a bool is expected
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
27 type_T * |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
28 get_type_ptr(garray_T *type_gap) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 type_T *type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 if (ga_grow(type_gap, 1) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 return NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 type = ALLOC_CLEAR_ONE(type_T); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 if (type != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 ++type_gap->ga_len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 void |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 clear_type_list(garray_T *gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 while (gap->ga_len > 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 vim_free(((type_T **)gap->ga_data)[--gap->ga_len]); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 ga_clear(gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
51 /* |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
52 * Take a type that is using entries in a growarray and turn it into a type |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
53 * with allocated entries. |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
54 */ |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
55 type_T * |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
56 alloc_type(type_T *type) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
57 { |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
58 type_T *ret; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
59 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
60 if (type == NULL) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
61 return NULL; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
62 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
63 // A fixed type never contains allocated types, return as-is. |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
64 if (type->tt_flags & TTFLAG_STATIC) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
65 return type; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
66 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
67 ret = ALLOC_ONE(type_T); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
68 *ret = *type; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
69 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
70 if (ret->tt_member != NULL) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
71 ret->tt_member = alloc_type(ret->tt_member); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
72 if (type->tt_args != NULL) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
73 { |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
74 int i; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
75 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
76 ret->tt_args = ALLOC_MULT(type_T *, type->tt_argcount); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
77 if (ret->tt_args != NULL) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
78 for (i = 0; i < type->tt_argcount; ++i) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
79 ret->tt_args[i] = alloc_type(type->tt_args[i]); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
80 } |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
81 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
82 return ret; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
83 } |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
84 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
85 /* |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
86 * Free a type that was created with alloc_type(). |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
87 */ |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
88 void |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
89 free_type(type_T *type) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
90 { |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
91 int i; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
92 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
93 if (type == NULL || (type->tt_flags & TTFLAG_STATIC)) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
94 return; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
95 if (type->tt_args != NULL) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
96 { |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
97 for (i = 0; i < type->tt_argcount; ++i) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
98 free_type(type->tt_args[i]); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
99 vim_free(type->tt_args); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
100 } |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
101 free_type(type->tt_member); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
102 vim_free(type); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
103 } |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
104 |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 get_list_type(type_T *member_type, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 type_T *type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 // recognize commonly used types |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 if (member_type->tt_type == VAR_ANY) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 return &t_list_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 if (member_type->tt_type == VAR_VOID |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 || member_type->tt_type == VAR_UNKNOWN) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 return &t_list_empty; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 if (member_type->tt_type == VAR_BOOL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 return &t_list_bool; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 if (member_type->tt_type == VAR_NUMBER) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 return &t_list_number; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 if (member_type->tt_type == VAR_STRING) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 return &t_list_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 // Not a common type, create a new entry. |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
124 type = get_type_ptr(type_gap); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 if (type == NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 type->tt_type = VAR_LIST; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 type->tt_member = member_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 type->tt_argcount = 0; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 type->tt_args = NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 get_dict_type(type_T *member_type, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 type_T *type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 // recognize commonly used types |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 if (member_type->tt_type == VAR_ANY) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 return &t_dict_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 if (member_type->tt_type == VAR_VOID |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 || member_type->tt_type == VAR_UNKNOWN) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 return &t_dict_empty; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 if (member_type->tt_type == VAR_BOOL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 return &t_dict_bool; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 if (member_type->tt_type == VAR_NUMBER) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 return &t_dict_number; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 if (member_type->tt_type == VAR_STRING) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 return &t_dict_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 // Not a common type, create a new entry. |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
153 type = get_type_ptr(type_gap); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 if (type == NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 type->tt_type = VAR_DICT; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 type->tt_member = member_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 type->tt_argcount = 0; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 type->tt_args = NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 * Allocate a new type for a function. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 alloc_func_type(type_T *ret_type, int argcount, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 { |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
169 type_T *type = get_type_ptr(type_gap); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 if (type == NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 type->tt_type = VAR_FUNC; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 type->tt_member = ret_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 type->tt_argcount = argcount; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 type->tt_args = NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 * Get a function type, based on the return type "ret_type". |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 * If "argcount" is -1 or 0 a predefined type can be used. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 * If "argcount" > 0 always create a new type, so that arguments can be added. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 get_func_type(type_T *ret_type, int argcount, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 // recognize commonly used types |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 if (argcount <= 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 if (ret_type == &t_unknown) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 // (argcount == 0) is not possible |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 return &t_func_unknown; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 if (ret_type == &t_void) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 if (argcount == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 return &t_func_0_void; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 return &t_func_void; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 if (ret_type == &t_any) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 if (argcount == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 return &t_func_0_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 return &t_func_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 if (ret_type == &t_number) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 if (argcount == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 return &t_func_0_number; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 return &t_func_number; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 if (ret_type == &t_string) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 if (argcount == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 return &t_func_0_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 return &t_func_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 return alloc_func_type(ret_type, argcount, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 * For a function type, reserve space for "argcount" argument types (including |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 * vararg). |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 int |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 func_type_add_arg_types( |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 type_T *functype, |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 int argcount, |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 // To make it easy to free the space needed for the argument types, add the |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 // pointer to type_gap. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 if (ga_grow(type_gap, 1) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 return FAIL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 functype->tt_args = ALLOC_CLEAR_MULT(type_T *, argcount); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 if (functype->tt_args == NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 return FAIL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 ((type_T **)type_gap->ga_data)[type_gap->ga_len] = |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 (void *)functype->tt_args; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 ++type_gap->ga_len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 return OK; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 * Get a type_T for a typval_T. |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
254 * "type_gap" is used to temporarily create types in. |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 */ |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
256 static type_T * |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
257 typval2type_int(typval_T *tv, garray_T *type_gap) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 { |
22190
da851f3b6a0b
patch 8.2.1644: Vim9: cannot assign 1 and 0 to bool at script level
Bram Moolenaar <Bram@vim.org>
parents:
22184
diff
changeset
|
259 type_T *type; |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
260 type_T *member_type = &t_any; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
261 int argcount = 0; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 if (tv->v_type == VAR_NUMBER) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 return &t_number; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 if (tv->v_type == VAR_BOOL) |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
266 return &t_bool; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 if (tv->v_type == VAR_STRING) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 return &t_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 if (tv->v_type == VAR_LIST) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 { |
22419
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
272 list_T *l = tv->vval.v_list; |
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
273 listitem_T *li; |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
274 |
22419
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
275 if (l == NULL || l->lv_first == NULL) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 return &t_list_empty; |
22419
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
277 if (l->lv_first == &range_list_item) |
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
278 return &t_list_number; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
280 // Use the common type of all members. |
22419
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
281 member_type = typval2type(&l->lv_first->li_tv, type_gap); |
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22347
diff
changeset
|
282 for (li = l->lv_first->li_next; li != NULL; li = li->li_next) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
283 common_type(typval2type(&li->li_tv, type_gap), |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
284 member_type, &member_type, type_gap); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 return get_list_type(member_type, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 if (tv->v_type == VAR_DICT) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 dict_iterator_T iter; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 typval_T *value; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 if (tv->vval.v_dict == NULL |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 || tv->vval.v_dict->dv_hashtab.ht_used == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 return &t_dict_empty; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
297 // Use the common type of all values. |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 dict_iterate_start(tv, &iter); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 dict_iterate_next(&iter, &value); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 member_type = typval2type(value, type_gap); |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
301 while (dict_iterate_next(&iter, &value) != NULL) |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
302 common_type(typval2type(value, type_gap), |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
303 member_type, &member_type, type_gap); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 return get_dict_type(member_type, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 if (tv->v_type == VAR_FUNC || tv->v_type == VAR_PARTIAL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 char_u *name = NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 ufunc_T *ufunc = NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 if (tv->v_type == VAR_PARTIAL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 if (tv->vval.v_partial->pt_func != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 ufunc = tv->vval.v_partial->pt_func; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 name = tv->vval.v_partial->pt_name; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 name = tv->vval.v_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 if (name != NULL) |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
322 { |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
323 int idx = find_internal_func(name); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
324 |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
325 if (idx >= 0) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
326 { |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
327 // TODO: get actual arg count and types |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
328 argcount = -1; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
329 member_type = internal_func_ret_type(idx, 0, NULL); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
330 } |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
331 else |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
332 ufunc = find_func(name, FALSE, NULL); |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
333 } |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 if (ufunc != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 // May need to get the argument types from default values by |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 // compiling the function. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 if (ufunc->uf_def_status == UF_TO_BE_COMPILED |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 && compile_def_function(ufunc, TRUE, NULL) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 return NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 if (ufunc->uf_func_type != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 return ufunc->uf_func_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
346 type = get_type_ptr(type_gap); |
22190
da851f3b6a0b
patch 8.2.1644: Vim9: cannot assign 1 and 0 to bool at script level
Bram Moolenaar <Bram@vim.org>
parents:
22184
diff
changeset
|
347 if (type == NULL) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 return NULL; |
22190
da851f3b6a0b
patch 8.2.1644: Vim9: cannot assign 1 and 0 to bool at script level
Bram Moolenaar <Bram@vim.org>
parents:
22184
diff
changeset
|
349 type->tt_type = tv->v_type; |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
350 type->tt_argcount = argcount; |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
351 type->tt_member = member_type; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 |
22190
da851f3b6a0b
patch 8.2.1644: Vim9: cannot assign 1 and 0 to bool at script level
Bram Moolenaar <Bram@vim.org>
parents:
22184
diff
changeset
|
353 return type; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 /* |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
357 * Return TRUE if "tv" is not a bool but should be converted to bool. |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
358 */ |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
359 int |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
360 need_convert_to_bool(type_T *type, typval_T *tv) |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
361 { |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
362 return type != NULL && type == &t_bool && tv->v_type != VAR_BOOL |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
363 && (tv->v_type == VAR_NUMBER |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
364 && (tv->vval.v_number == 0 || tv->vval.v_number == 1)); |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
365 } |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
366 |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
367 /* |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
368 * Get a type_T for a typval_T. |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
369 * "type_list" is used to temporarily create types in. |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
370 */ |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
371 type_T * |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
372 typval2type(typval_T *tv, garray_T *type_gap) |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
373 { |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
374 type_T *type = typval2type_int(tv, type_gap); |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
375 |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
376 if (type != NULL && type != &t_bool |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
377 && (tv->v_type == VAR_NUMBER |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
378 && (tv->vval.v_number == 0 || tv->vval.v_number == 1))) |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
379 { |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
380 type_T *newtype = get_type_ptr(type_gap); |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
381 |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
382 // Number 0 and 1 and expression with "&&" or "||" can also be used |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
383 // for bool. |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
384 if (newtype != NULL) |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
385 { |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
386 *newtype = *type; |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
387 newtype->tt_flags = TTFLAG_BOOL_OK; |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
388 type = newtype; |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
389 } |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
390 } |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
391 return type; |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
392 } |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
393 |
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
394 /* |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 * Get a type_T for a typval_T, used for v: variables. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 * "type_list" is used to temporarily create types in. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 typval2type_vimvar(typval_T *tv, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 if (tv->v_type == VAR_LIST) // e.g. for v:oldfiles |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 return &t_list_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 if (tv->v_type == VAR_DICT) // e.g. for v:completed_item |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 return &t_dict_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 return typval2type(tv, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 * Return FAIL if "expected" and "actual" don't match. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 int |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
413 check_typval_type(type_T *expected, typval_T *actual_tv, int argidx) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 garray_T type_list; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 type_T *actual_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 int res = FAIL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 ga_init2(&type_list, sizeof(type_T *), 10); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 actual_type = typval2type(actual_tv, &type_list); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 if (actual_type != NULL) |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
422 res = check_type(expected, actual_type, TRUE, argidx); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 clear_type_list(&type_list); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 return res; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 void |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 type_mismatch(type_T *expected, type_T *actual) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 { |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
430 arg_type_mismatch(expected, actual, 0); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 void |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 arg_type_mismatch(type_T *expected, type_T *actual, int argidx) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 char *tofree1, *tofree2; |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
437 char *typename1 = type_name(expected, &tofree1); |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
438 char *typename2 = type_name(actual, &tofree2); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
440 if (argidx > 0) |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
441 semsg(_(e_argument_nr_type_mismatch_expected_str_but_got_str), |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
442 argidx, typename1, typename2); |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
443 else |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
444 semsg(_(e_type_mismatch_expected_str_but_got_str), |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
445 typename1, typename2); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 vim_free(tofree1); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 vim_free(tofree2); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 * Check if the expected and actual types match. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 * Does not allow for assigning "any" to a specific type. |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
453 * When "argidx" > 0 it is included in the error message. |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 int |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
456 check_type(type_T *expected, type_T *actual, int give_msg, int argidx) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 int ret = OK; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 // When expected is "unknown" we accept any actual type. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 // When expected is "any" we accept any actual type except "void". |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 if (expected->tt_type != VAR_UNKNOWN |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 && !(expected->tt_type == VAR_ANY && actual->tt_type != VAR_VOID)) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 { |
22347
712bc35842aa
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Bram Moolenaar <Bram@vim.org>
parents:
22322
diff
changeset
|
466 // tt_type should match, except that a "partial" can be assigned to a |
712bc35842aa
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Bram Moolenaar <Bram@vim.org>
parents:
22322
diff
changeset
|
467 // variable with type "func". |
712bc35842aa
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Bram Moolenaar <Bram@vim.org>
parents:
22322
diff
changeset
|
468 if (!(expected->tt_type == actual->tt_type |
712bc35842aa
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Bram Moolenaar <Bram@vim.org>
parents:
22322
diff
changeset
|
469 || (expected->tt_type == VAR_FUNC |
712bc35842aa
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Bram Moolenaar <Bram@vim.org>
parents:
22322
diff
changeset
|
470 && actual->tt_type == VAR_PARTIAL))) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 { |
22202
7899b4e2880c
patch 8.2.1650: Vim9: result of && and || expression is not bool in script
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
472 if (expected->tt_type == VAR_BOOL |
22184
2463b3d89ce2
patch 8.2.1641: Vim9: cannot use 0 or 1 where a bool is expected
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
473 && (actual->tt_flags & TTFLAG_BOOL_OK)) |
2463b3d89ce2
patch 8.2.1641: Vim9: cannot use 0 or 1 where a bool is expected
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
474 // Using number 0 or 1 for bool is OK. |
2463b3d89ce2
patch 8.2.1641: Vim9: cannot use 0 or 1 where a bool is expected
Bram Moolenaar <Bram@vim.org>
parents:
22004
diff
changeset
|
475 return OK; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 if (give_msg) |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
477 arg_type_mismatch(expected, actual, argidx); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 return FAIL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 if (expected->tt_type == VAR_DICT || expected->tt_type == VAR_LIST) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 // "unknown" is used for an empty list or dict |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 if (actual->tt_member != &t_unknown) |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
484 ret = check_type(expected->tt_member, actual->tt_member, |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
485 FALSE, 0); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 else if (expected->tt_type == VAR_FUNC) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 if (expected->tt_member != &t_unknown) |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
490 ret = check_type(expected->tt_member, actual->tt_member, |
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
491 FALSE, 0); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 if (ret == OK && expected->tt_argcount != -1 |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
493 && actual->tt_argcount != -1 |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 && (actual->tt_argcount < expected->tt_min_argcount |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 || actual->tt_argcount > expected->tt_argcount)) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 ret = FAIL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 if (expected->tt_args != NULL && actual->tt_args != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 int i; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 for (i = 0; i < expected->tt_argcount; ++i) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 // Allow for using "any" argument type, lambda's have them. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 if (actual->tt_args[i] != &t_any && check_type( |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
504 expected->tt_args[i], actual->tt_args[i], FALSE, 0) |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 ret = FAIL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 if (ret == FAIL && give_msg) |
22004
a9e60176dcd3
patch 8.2.1551: Vim9: error for argument type does not mention the number
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
513 arg_type_mismatch(expected, actual, argidx); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 return ret; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 * Skip over a type definition and return a pointer to just after it. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 * When "optional" is TRUE then a leading "?" is accepted. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 char_u * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 skip_type(char_u *start, int optional) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 char_u *p = start; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 if (optional && *p == '?') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 while (ASCII_ISALNUM(*p) || *p == '_') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 // Skip over "<type>"; this is permissive about white space. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 if (*skipwhite(p) == '<') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 p = skipwhite(p); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 p = skip_type(skipwhite(p + 1), FALSE); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 p = skipwhite(p); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 if (*p == '>') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 else if ((*p == '(' || (*p == ':' && VIM_ISWHITE(p[1]))) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 && STRNCMP("func", start, 4) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 if (*p == '(') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 // handle func(args): type |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 while (*p != ')' && *p != NUL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 char_u *sp = p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 if (STRNCMP(p, "...", 3) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 p += 3; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 p = skip_type(p, TRUE); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 if (p == sp) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 return p; // syntax error |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 if (*p == ',') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 p = skipwhite(p + 1); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 if (*p == ')') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 if (p[1] == ':') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 p = skip_type(skipwhite(p + 2), FALSE); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 // handle func: return_type |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 p = skip_type(skipwhite(p + 1), FALSE); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 return p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 * Parse the member type: "<type>" and return "type" with the member set. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 * Use "type_gap" if a new type needs to be added. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 * Returns NULL in case of failure. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 static type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 parse_type_member(char_u **arg, type_T *type, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 type_T *member_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 int prev_called_emsg = called_emsg; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 if (**arg != '<') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 if (*skipwhite(*arg) == '<') |
21909
a211bca98bc3
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
592 semsg(_(e_no_white_space_allowed_before_str), "<"); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 else |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21803
diff
changeset
|
594 emsg(_(e_missing_type)); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 *arg = skipwhite(*arg + 1); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 member_type = parse_type(arg, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 *arg = skipwhite(*arg); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 if (**arg != '>' && called_emsg == prev_called_emsg) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21803
diff
changeset
|
604 emsg(_(e_missing_gt_after_type)); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 ++*arg; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 if (type->tt_type == VAR_LIST) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 return get_list_type(member_type, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 return get_dict_type(member_type, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 * Parse a type at "arg" and advance over it. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 * Return &t_any for failure. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 type_T * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 parse_type(char_u **arg, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 char_u *p = *arg; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 size_t len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 // skip over the first word |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 while (ASCII_ISALNUM(*p) || *p == '_') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 len = p - *arg; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 switch (**arg) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 case 'a': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 if (len == 3 && STRNCMP(*arg, "any", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 case 'b': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 if (len == 4 && STRNCMP(*arg, "bool", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 return &t_bool; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 if (len == 4 && STRNCMP(*arg, "blob", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 return &t_blob; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 case 'c': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 if (len == 7 && STRNCMP(*arg, "channel", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 return &t_channel; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 case 'd': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 if (len == 4 && STRNCMP(*arg, "dict", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 return parse_type_member(arg, &t_dict_any, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 case 'f': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 if (len == 5 && STRNCMP(*arg, "float", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 #ifdef FEAT_FLOAT |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 return &t_float; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 #else |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21803
diff
changeset
|
671 emsg(_(e_this_vim_is_not_compiled_with_float_support)); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 #endif |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 if (len == 4 && STRNCMP(*arg, "func", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 type_T *type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 type_T *ret_type = &t_unknown; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 int argcount = -1; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 int flags = 0; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 int first_optional = -1; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 type_T *arg_type[MAX_FUNC_ARGS + 1]; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 // func({type}, ...{type}): {type} |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 if (**arg == '(') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 // "func" may or may not return a value, "func()" does |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 // not return a value. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 ret_type = &t_void; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 p = ++*arg; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 argcount = 0; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 while (*p != NUL && *p != ')') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 if (*p == '?') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 if (first_optional == -1) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 first_optional = argcount; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 else if (STRNCMP(p, "...", 3) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 flags |= TTFLAG_VARARGS; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 p += 3; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 else if (first_optional != -1) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21803
diff
changeset
|
709 emsg(_(e_mandatory_argument_after_optional_argument)); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 arg_type[argcount++] = parse_type(&p, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 // Nothing comes after "...{type}". |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 if (flags & TTFLAG_VARARGS) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 if (*p != ',' && *skipwhite(p) == ',') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 { |
21909
a211bca98bc3
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
721 semsg(_(e_no_white_space_allowed_before_str), ","); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 if (*p == ',') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 ++p; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 if (!VIM_ISWHITE(*p)) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 { |
21909
a211bca98bc3
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
729 semsg(_(e_white_space_required_after_str), ","); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 p = skipwhite(p); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 if (argcount == MAX_FUNC_ARGS) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21803
diff
changeset
|
736 emsg(_(e_too_many_argument_types)); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 p = skipwhite(p); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 if (*p != ')') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 emsg(_(e_missing_close)); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 *arg = p + 1; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 if (**arg == ':') |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 // parse return type |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 ++*arg; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 if (!VIM_ISWHITE(**arg)) |
21909
a211bca98bc3
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
754 semsg(_(e_white_space_required_after_str), ":"); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 *arg = skipwhite(*arg); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 ret_type = parse_type(arg, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 if (flags == 0 && first_optional == -1 && argcount <= 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 type = get_func_type(ret_type, argcount, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 type = alloc_func_type(ret_type, argcount, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 type->tt_flags = flags; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 if (argcount > 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 type->tt_argcount = argcount; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 type->tt_min_argcount = first_optional == -1 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 ? argcount : first_optional; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 if (func_type_add_arg_types(type, argcount, |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 type_gap) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 mch_memmove(type->tt_args, arg_type, |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 sizeof(type_T *) * argcount); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 return type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 case 'j': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 if (len == 3 && STRNCMP(*arg, "job", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 return &t_job; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 case 'l': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 if (len == 4 && STRNCMP(*arg, "list", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 return parse_type_member(arg, &t_list_any, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 case 'n': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 if (len == 6 && STRNCMP(*arg, "number", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 return &t_number; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 case 's': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 if (len == 6 && STRNCMP(*arg, "string", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 return &t_string; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 case 'v': |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 if (len == 4 && STRNCMP(*arg, "void", len) == 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 *arg += len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 return &t_void; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21803
diff
changeset
|
816 semsg(_(e_type_not_recognized_str), *arg); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 return &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 * Check if "type1" and "type2" are exactly the same. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 static int |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 equal_type(type_T *type1, type_T *type2) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 int i; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 if (type1->tt_type != type2->tt_type) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 return FALSE; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 switch (type1->tt_type) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 case VAR_UNKNOWN: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 case VAR_ANY: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 case VAR_VOID: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 case VAR_SPECIAL: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 case VAR_BOOL: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 case VAR_NUMBER: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 case VAR_FLOAT: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 case VAR_STRING: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 case VAR_BLOB: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 case VAR_JOB: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 case VAR_CHANNEL: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 break; // not composite is always OK |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 case VAR_LIST: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 case VAR_DICT: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 return equal_type(type1->tt_member, type2->tt_member); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 case VAR_FUNC: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 case VAR_PARTIAL: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 if (!equal_type(type1->tt_member, type2->tt_member) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 || type1->tt_argcount != type2->tt_argcount) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 return FALSE; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 if (type1->tt_argcount < 0 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 || type1->tt_args == NULL || type2->tt_args == NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 return TRUE; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 for (i = 0; i < type1->tt_argcount; ++i) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 if (!equal_type(type1->tt_args[i], type2->tt_args[i])) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 return FALSE; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 return TRUE; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 return TRUE; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 * Find the common type of "type1" and "type2" and put it in "dest". |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 * "type2" and "dest" may be the same. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 void |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 if (equal_type(type1, type2)) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 *dest = type1; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 return; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 |
22322
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
876 // If either is VAR_UNKNOWN use the other type. An empty list/dict has no |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
877 // specific type. |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
878 if (type1->tt_type == VAR_UNKNOWN) |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
879 { |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
880 *dest = type2; |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
881 return; |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
882 } |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
883 if (type2->tt_type == VAR_UNKNOWN) |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
884 { |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
885 *dest = type1; |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
886 return; |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
887 } |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
888 |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 if (type1->tt_type == type2->tt_type) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 if (type1->tt_type == VAR_LIST || type2->tt_type == VAR_DICT) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 type_T *common; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 common_type(type1->tt_member, type2->tt_member, &common, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 if (type1->tt_type == VAR_LIST) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 *dest = get_list_type(common, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 *dest = get_dict_type(common, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 return; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 if (type1->tt_type == VAR_FUNC) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 type_T *common; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 common_type(type1->tt_member, type2->tt_member, &common, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 if (type1->tt_argcount == type2->tt_argcount |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 && type1->tt_argcount >= 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 int argcount = type1->tt_argcount; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 int i; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 *dest = alloc_func_type(common, argcount, type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 if (type1->tt_args != NULL && type2->tt_args != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 if (func_type_add_arg_types(*dest, argcount, |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 type_gap) == OK) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 for (i = 0; i < argcount; ++i) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 common_type(type1->tt_args[i], type2->tt_args[i], |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 &(*dest)->tt_args[i], type_gap); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 *dest = alloc_func_type(common, -1, type_gap); |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
925 // Use the minimum of min_argcount. |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
926 (*dest)->tt_min_argcount = |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
927 type1->tt_min_argcount < type2->tt_min_argcount |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
928 ? type1->tt_min_argcount : type2->tt_min_argcount; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 return; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 *dest = &t_any; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
936 /* |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
937 * Get the member type of a dict or list from the items on the stack. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
938 * "stack_top" points just after the last type on the type stack. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
939 * For a list "skip" is 1, for a dict "skip" is 2, keys are skipped. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
940 * Returns &t_void for an empty list or dict. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
941 * Otherwise finds the common type of all items. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
942 */ |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
943 type_T * |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
944 get_member_type_from_stack( |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
945 type_T **stack_top, |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
946 int count, |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
947 int skip, |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
948 garray_T *type_gap) |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
949 { |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
950 int i; |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
951 type_T *result; |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
952 type_T *type; |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
953 |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
954 // Use "any" for an empty list or dict. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
955 if (count == 0) |
22322
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
956 return &t_unknown; |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
957 |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
958 // Use the first value type for the list member type, then find the common |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
959 // type from following items. |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
960 result = *(stack_top -(count * skip) + skip - 1); |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
961 for (i = 1; i < count; ++i) |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
962 { |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
963 if (result == &t_any) |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
964 break; // won't get more common |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
965 type = *(stack_top -((count - i) * skip) + skip - 1); |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
966 common_type(type, result, &result, type_gap); |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
967 } |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
968 |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
969 return result; |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
970 } |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21711
diff
changeset
|
971 |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 char * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 vartype_name(vartype_T type) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 switch (type) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 case VAR_UNKNOWN: break; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 case VAR_ANY: return "any"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 case VAR_VOID: return "void"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 case VAR_SPECIAL: return "special"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 case VAR_BOOL: return "bool"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 case VAR_NUMBER: return "number"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 case VAR_FLOAT: return "float"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 case VAR_STRING: return "string"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 case VAR_BLOB: return "blob"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 case VAR_JOB: return "job"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 case VAR_CHANNEL: return "channel"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 case VAR_LIST: return "list"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 case VAR_DICT: return "dict"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 case VAR_FUNC: |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 case VAR_PARTIAL: return "func"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 return "unknown"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 /* |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 * Return the name of a type. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 * The result may be in allocated memory, in which case "tofree" is set. |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 */ |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 char * |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 type_name(type_T *type, char **tofree) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 char *name = vartype_name(type->tt_type); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 *tofree = NULL; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 if (type->tt_type == VAR_LIST || type->tt_type == VAR_DICT) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 char *member_free; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 char *member_name = type_name(type->tt_member, &member_free); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 size_t len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 len = STRLEN(name) + STRLEN(member_name) + 3; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 *tofree = alloc(len); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 if (*tofree != NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 vim_snprintf(*tofree, len, "%s<%s>", name, member_name); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 vim_free(member_free); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 return *tofree; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 if (type->tt_type == VAR_FUNC) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 garray_T ga; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 int i; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 int varargs = (type->tt_flags & TTFLAG_VARARGS) ? 1 : 0; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 ga_init2(&ga, 1, 100); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 if (ga_grow(&ga, 20) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 return "[unknown]"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 STRCPY(ga.ga_data, "func("); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 ga.ga_len += 5; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 for (i = 0; i < type->tt_argcount; ++i) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 char *arg_free; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 char *arg_type; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 int len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 if (type->tt_args == NULL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 arg_type = "[unknown]"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 arg_type = type_name(type->tt_args[i], &arg_free); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 if (i > 0) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 STRCPY((char *)ga.ga_data + ga.ga_len, ", "); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 ga.ga_len += 2; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 len = (int)STRLEN(arg_type); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 if (ga_grow(&ga, len + 8) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 vim_free(arg_free); |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1053 ga_clear(&ga); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 return "[unknown]"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 if (varargs && i == type->tt_argcount - 1) |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1057 ga_concat(&ga, (char_u *)"..."); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 else if (i >= type->tt_min_argcount) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 *((char *)ga.ga_data + ga.ga_len++) = '?'; |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1060 ga_concat(&ga, (char_u *)arg_type); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 vim_free(arg_free); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 } |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1063 if (type->tt_argcount < 0) |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1064 // any number of arguments |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1065 ga_concat(&ga, (char_u *)"..."); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 if (type->tt_member == &t_void) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 STRCPY((char *)ga.ga_data + ga.ga_len, ")"); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 else |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 char *ret_free; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 char *ret_name = type_name(type->tt_member, &ret_free); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 int len; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 len = (int)STRLEN(ret_name) + 4; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 if (ga_grow(&ga, len) == FAIL) |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 { |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 vim_free(ret_free); |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1079 ga_clear(&ga); |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 return "[unknown]"; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 STRCPY((char *)ga.ga_data + ga.ga_len, "): "); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 STRCPY((char *)ga.ga_data + ga.ga_len + 3, ret_name); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 vim_free(ret_free); |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 } |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
1086 *tofree = ga.ga_data; |
21711
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 return ga.ga_data; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 return name; |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 } |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 |
d2dee69de7c7
patch 8.2.1405: Vim9: vim9compile.c is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 #endif // FEAT_EVAL |