Patch 8.2.0340
Problem:    Vim9: function and partial types not tested.
Solution:   Support more for partial, add tests.
Files:      src/vim9.h, src/vim9compile.c, src/vim9execute.c,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.0339/src/vim9.h  2020-02-29 23:23:44.484659204 +0100
--- src/vim9.h  2020-03-01 14:59:49.381576778 +0100
***************
*** 215,220 ****
--- 215,221 ----
  #endif
        channel_T           *channel;
        job_T               *job;
+       partial_T           *partial;
        jump_T              jump;
        forloop_T           forloop;
        try_T               try;
*** ../vim-8.2.0339/src/vim9compile.c   2020-03-01 14:04:42.224689018 +0100
--- src/vim9compile.c   2020-03-01 15:01:59.453119645 +0100
***************
*** 706,711 ****
--- 706,728 ----
  }
  
  /*
+  * 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,3612 ****
                generate_PUSHFUNC(cctx, NULL);
                break;
            case VAR_PARTIAL:
!               // generate_PUSHPARTIAL(cctx, NULL);
!               emsg("Partial type not supported yet");
                break;
            case VAR_LIST:
                generate_NEWLIST(cctx, 0);
--- 3622,3628 ----
                generate_PUSHFUNC(cctx, NULL);
                break;
            case VAR_PARTIAL:
!               generate_PUSHPARTIAL(cctx, NULL);
                break;
            case VAR_LIST:
                generate_NEWLIST(cctx, 0);
***************
*** 5228,5234 ****
            break;
  
        case ISN_PUSHPARTIAL:
!           // TODO
            break;
  
        case ISN_PUSHJOB:
--- 5244,5250 ----
            break;
  
        case ISN_PUSHPARTIAL:
!           partial_unref(isn->isn_arg.partial);
            break;
  
        case ISN_PUSHJOB:
*** ../vim-8.2.0339/src/vim9execute.c   2020-02-29 23:23:44.484659204 +0100
--- src/vim9execute.c   2020-03-01 15:31:12.490999220 +0100
***************
*** 873,882 ****
                        break;
                    case ISN_PUSHFUNC:
                        tv->v_type = VAR_FUNC;
!                       tv->vval.v_string = vim_strsave(iptr->isn_arg.string);
                        break;
                    case ISN_PUSHPARTIAL:
!                       tv->v_type = VAR_UNKNOWN;
                        break;
                    case ISN_PUSHCHANNEL:
  #ifdef FEAT_JOB_CHANNEL
--- 873,889 ----
                        break;
                    case ISN_PUSHFUNC:
                        tv->v_type = VAR_FUNC;
!                       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_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,1884 ****
                }
                break;
            case ISN_PUSHFUNC:
!               smsg("%4d PUSHFUNC \"%s\"", current, iptr->isn_arg.string);
                break;
            case ISN_PUSHPARTIAL:
!               // TODO
!               smsg("%4d PUSHPARTIAL", current);
                break;
            case ISN_PUSHCHANNEL:
  #ifdef FEAT_JOB_CHANNEL
--- 1881,1900 ----
                }
                break;
            case ISN_PUSHFUNC:
!               {
!                   char *name = (char *)iptr->isn_arg.string;
! 
!                   smsg("%4d PUSHFUNC \"%s\"", current,
!                                              name == NULL ? "[none]" : name);
!               }
                break;
            case ISN_PUSHPARTIAL:
!               {
!                   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
*** ../vim-8.2.0339/src/testdir/test_vim9_script.vim    2020-03-01 
14:04:42.224689018 +0100
--- src/testdir/test_vim9_script.vim    2020-03-01 14:53:31.735115244 +0100
***************
*** 60,66 ****
    if has('float')
      let float1: float = 3.4
    endif
!   let party: partial = funcref('Test_syntax')
  
    g:newvar = 'new'
    assert_equal('new', g:newvar)
--- 60,69 ----
    if has('float')
      let float1: float = 3.4
    endif
!   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)
*** ../vim-8.2.0339/src/version.c       2020-03-01 14:04:42.224689018 +0100
--- src/version.c       2020-03-01 15:00:57.001335676 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     340,
  /**/

-- 
Drink wet cement and get really stoned.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202003011437.021EbBpl014619%40masaka.moolenaar.net.

Raspunde prin e-mail lui