diff src/vim9execute.c @ 24434:602e528a8e43 v8.2.2757

patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate Commit: https://github.com/vim/vim/commit/68452177ca4cda4a9d5f93892e437447cf9404c8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 12 21:21:02 2021 +0200 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate Problem: Vim9: blob tests for legacy and Vim9 script are separate. Solution: Add CheckLegacyAndVim9Success(). Make blob index assign work.
author Bram Moolenaar <Bram@vim.org>
date Mon, 12 Apr 2021 21:30:04 +0200
parents aa150abca273
children 3e1886f1e875
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2219,6 +2219,10 @@ call_def_function(
 			    clear_tv(tv);
 			}
 		    }
+		    else if (status == OK && dest_type == VAR_BLOB)
+		    {
+			// TODO
+		    }
 		    else
 		    {
 			status = FAIL;
@@ -2236,6 +2240,60 @@ call_def_function(
 		}
 		break;
 
+	    // store value in blob range
+	    case ISN_STORERANGE:
+		{
+		    typval_T	*tv_idx1 = STACK_TV_BOT(-3);
+		    typval_T	*tv_idx2 = STACK_TV_BOT(-2);
+		    typval_T	*tv_dest = STACK_TV_BOT(-1);
+		    int		status = OK;
+
+		    // Stack contains:
+		    // -4 value to be stored
+		    // -3 first index or "none"
+		    // -2 second index or "none"
+		    // -1 destination blob
+		    tv = STACK_TV_BOT(-4);
+		    if (tv_dest->v_type != VAR_BLOB)
+		    {
+			status = FAIL;
+			emsg(_(e_blob_required));
+		    }
+		    else
+		    {
+			varnumber_T n1;
+			varnumber_T n2;
+			int	    error = FALSE;
+
+			n1 = tv_get_number_chk(tv_idx1, &error);
+			if (error)
+			    status = FAIL;
+			else
+			{
+			    if (tv_idx2->v_type == VAR_SPECIAL
+					&& tv_idx2->vval.v_number == VVAL_NONE)
+				n2 = blob_len(tv_dest->vval.v_blob) - 1;
+			    else
+				n2 = tv_get_number_chk(tv_idx2, &error);
+			    if (error)
+				status = FAIL;
+			    else
+				status = blob_set_range(tv_dest->vval.v_blob,
+								   n1, n2, tv);
+			}
+		    }
+
+		    clear_tv(tv_idx1);
+		    clear_tv(tv_idx2);
+		    clear_tv(tv_dest);
+		    ectx.ec_stack.ga_len -= 4;
+		    clear_tv(tv);
+
+		    if (status == FAIL)
+			goto on_error;
+		}
+		break;
+
 	    // load or store variable or argument from outer scope
 	    case ISN_LOADOUTER:
 	    case ISN_STOREOUTER:
@@ -4362,6 +4420,10 @@ ex_disassemble(exarg_T *eap)
 		}
 		break;
 
+	    case ISN_STORERANGE:
+		smsg("%4d STORERANGE", current);
+		break;
+
 	    // constants
 	    case ISN_PUSHNR:
 		smsg("%4d PUSHNR %lld", current,