@@ -1432,6 +1432,26 @@ generate_NEWFUNC(cctx_T *cctx, char_u *lambda_name, char_u *func_name)
14321432 return OK ;
14331433}
14341434
1435+ /*
1436+ * Generate an ISN_DEF instruction: list functions
1437+ */
1438+ static int
1439+ generate_DEF (cctx_T * cctx , char_u * name , size_t len )
1440+ {
1441+ isn_T * isn ;
1442+
1443+ RETURN_OK_IF_SKIP (cctx );
1444+ if ((isn = generate_instr (cctx , ISN_DEF )) == NULL )
1445+ return FAIL ;
1446+ if (len > 0 )
1447+ {
1448+ isn -> isn_arg .string = vim_strnsave (name , len );
1449+ if (isn -> isn_arg .string == NULL )
1450+ return FAIL ;
1451+ }
1452+ return OK ;
1453+ }
1454+
14351455/*
14361456 * Generate an ISN_JUMP instruction.
14371457 */
@@ -4801,6 +4821,27 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
48014821 return NULL ;
48024822 }
48034823
4824+ if (* name_start == '/' )
4825+ {
4826+ name_end = skip_regexp (name_start + 1 , '/' , TRUE);
4827+ if (* name_end == '/' )
4828+ ++ name_end ;
4829+ eap -> nextcmd = check_nextcmd (name_end );
4830+ }
4831+ if (name_end == name_start || * skipwhite (name_end ) != '(' )
4832+ {
4833+ if (!ends_excmd2 (name_start , name_end ))
4834+ {
4835+ semsg (_ (e_invalid_command_str ), eap -> cmd );
4836+ return NULL ;
4837+ }
4838+
4839+ // "def" or "def Name": list functions
4840+ if (generate_DEF (cctx , name_start , name_end - name_start ) == FAIL )
4841+ return NULL ;
4842+ return eap -> nextcmd == NULL ? (char_u * )"" : eap -> nextcmd ;
4843+ }
4844+
48044845 // Only g:Func() can use a namespace.
48054846 if (name_start [1 ] == ':' && !is_global )
48064847 {
@@ -7736,22 +7777,23 @@ delete_instr(isn_T *isn)
77367777{
77377778 switch (isn -> isn_type )
77387779 {
7780+ case ISN_DEF :
77397781 case ISN_EXEC :
7782+ case ISN_LOADB :
77407783 case ISN_LOADENV :
77417784 case ISN_LOADG :
7742- case ISN_LOADB :
7743- case ISN_LOADW :
7744- case ISN_LOADT :
77457785 case ISN_LOADOPT :
7746- case ISN_STRINGMEMBER :
7786+ case ISN_LOADT :
7787+ case ISN_LOADW :
77477788 case ISN_PUSHEXC :
7789+ case ISN_PUSHFUNC :
77487790 case ISN_PUSHS :
7791+ case ISN_STOREB :
77497792 case ISN_STOREENV :
77507793 case ISN_STOREG :
7751- case ISN_STOREB :
7752- case ISN_STOREW :
77537794 case ISN_STORET :
7754- case ISN_PUSHFUNC :
7795+ case ISN_STOREW :
7796+ case ISN_STRINGMEMBER :
77557797 vim_free (isn -> isn_arg .string );
77567798 break ;
77577799
0 commit comments