summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testdir/test_vim9_script.vim5
-rw-r--r--src/version.c2
-rw-r--r--src/vim9.h1
-rw-r--r--src/vim9compile.c22
-rw-r--r--src/vim9execute.c26
5 files changed, 47 insertions, 9 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index e5b3b476e..aace23978 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -60,7 +60,10 @@ def Test_assignment()
if has('float')
let float1: float = 3.4
endif
- let party: partial = funcref('Test_syntax')
+ let funky1: func
+ let funky2: func = function('len')
+ let party1: partial
+ let party2: partial = funcref('Test_syntax')
g:newvar = 'new'
assert_equal('new', g:newvar)
diff --git a/src/version.c b/src/version.c
index bdb40d312..3d126b068 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 340,
+/**/
339,
/**/
338,
diff --git a/src/vim9.h b/src/vim9.h
index 3a09c0fec..35d34e3af 100644
--- a/src/vim9.h
+++ b/src/vim9.h
@@ -215,6 +215,7 @@ typedef struct {
#endif
channel_T *channel;
job_T *job;
+ partial_T *partial;
jump_T jump;
forloop_T forloop;
try_T try;
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 4fb547844..64ed03800 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -706,6 +706,23 @@ generate_PUSHFUNC(cctx_T *cctx, char_u *name)
}
/*
+ * Generate an ISN_PUSHPARTIAL instruction with partial "part".
+ * Consumes "name".
+ */
+ static int
+generate_PUSHPARTIAL(cctx_T *cctx, partial_T *part)
+{
+ isn_T *isn;
+
+ if ((isn = generate_instr_type(cctx, ISN_PUSHPARTIAL,
+ &t_partial_any)) == NULL)
+ return FAIL;
+ isn->isn_arg.partial = part;
+
+ return OK;
+}
+
+/*
* Generate an ISN_STORE instruction.
*/
static int
@@ -3605,8 +3622,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
generate_PUSHFUNC(cctx, NULL);
break;
case VAR_PARTIAL:
- // generate_PUSHPARTIAL(cctx, NULL);
- emsg("Partial type not supported yet");
+ generate_PUSHPARTIAL(cctx, NULL);
break;
case VAR_LIST:
generate_NEWLIST(cctx, 0);
@@ -5228,7 +5244,7 @@ delete_instr(isn_T *isn)
break;
case ISN_PUSHPARTIAL:
- // TODO
+ partial_unref(isn->isn_arg.partial);
break;
case ISN_PUSHJOB:
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 9d187c4b4..be19b1f7f 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -873,10 +873,17 @@ call_def_function(
break;
case ISN_PUSHFUNC:
tv->v_type = VAR_FUNC;
- tv->vval.v_string = vim_strsave(iptr->isn_arg.string);
+ if (iptr->isn_arg.string == NULL)
+ tv->vval.v_string = NULL;
+ else
+ tv->vval.v_string =
+ vim_strsave(iptr->isn_arg.string);
break;
case ISN_PUSHPARTIAL:
- tv->v_type = VAR_UNKNOWN;
+ tv->v_type = VAR_PARTIAL;
+ tv->vval.v_partial = iptr->isn_arg.partial;
+ if (tv->vval.v_partial != NULL)
+ ++tv->vval.v_partial->pt_refcount;
break;
case ISN_PUSHCHANNEL:
#ifdef FEAT_JOB_CHANNEL
@@ -1874,11 +1881,20 @@ ex_disassemble(exarg_T *eap)
}
break;
case ISN_PUSHFUNC:
- smsg("%4d PUSHFUNC \"%s\"", current, iptr->isn_arg.string);
+ {
+ char *name = (char *)iptr->isn_arg.string;
+
+ smsg("%4d PUSHFUNC \"%s\"", current,
+ name == NULL ? "[none]" : name);
+ }
break;
case ISN_PUSHPARTIAL:
- // TODO
- smsg("%4d PUSHPARTIAL", current);
+ {
+ partial_T *part = iptr->isn_arg.partial;
+
+ smsg("%4d PUSHPARTIAL \"%s\"", current,
+ part == NULL ? "[none]" : (char *)partial_name(part));
+ }
break;
case ISN_PUSHCHANNEL:
#ifdef FEAT_JOB_CHANNEL