mirror of
https://github.com/vim/vim.git
synced 2025-10-23 08:44:20 -04:00
patch 9.1.1577: Vim9: no generic support yet
Problem: Vim9: no generic support yet
Solution: Add support for generic functions, funcrefs and object/class
methods (Yegappan Lakshmanan).
closes: #17313
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b486ed8266
commit
3416cee36f
@@ -1032,6 +1032,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
||||
compiletype_T compile_type;
|
||||
int funcref_isn_idx = -1;
|
||||
lvar_T *lvar = NULL;
|
||||
char_u *bracket_start = NULL;
|
||||
|
||||
if (eap->forceit)
|
||||
{
|
||||
@@ -1047,6 +1048,14 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
||||
++name_end;
|
||||
set_nextcmd(eap, name_end);
|
||||
}
|
||||
|
||||
if (*name_end == '<')
|
||||
{
|
||||
bracket_start = name_end;
|
||||
if (skip_generic_func_type_args(&name_end) == FAIL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (name_end == name_start || *skipwhite(name_end) != '(')
|
||||
{
|
||||
if (!ends_excmd2(name_start, name_end))
|
||||
@@ -1065,6 +1074,11 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
||||
return eap->nextcmd == NULL ? (char_u *)"" : eap->nextcmd;
|
||||
}
|
||||
|
||||
if (bracket_start != NULL)
|
||||
// generic function. The function name ends before the list of types
|
||||
// (opening angle bracket).
|
||||
name_end = bracket_start;
|
||||
|
||||
// Only g:Func() can use a namespace.
|
||||
if (name_start[1] == ':' && !is_global)
|
||||
{
|
||||
@@ -1104,7 +1118,8 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
||||
int save_KeyTyped = KeyTyped;
|
||||
KeyTyped = FALSE;
|
||||
|
||||
ufunc = define_function(eap, lambda_name.string, lines_to_free, 0, NULL, 0);
|
||||
ufunc = define_function(eap, lambda_name.string, lines_to_free, 0, NULL, 0,
|
||||
cctx);
|
||||
|
||||
KeyTyped = save_KeyTyped;
|
||||
|
||||
@@ -2105,7 +2120,7 @@ compile_lhs_set_type(cctx_T *cctx, lhs_T *lhs, char_u *var_end, int is_decl)
|
||||
}
|
||||
|
||||
p = skipwhite(var_end + 1);
|
||||
lhs->lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
|
||||
lhs->lhs_type = parse_type(&p, cctx->ctx_type_list, cctx->ctx_ufunc, cctx, TRUE);
|
||||
if (lhs->lhs_type == NULL)
|
||||
return FAIL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user