diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-11 20:26:34 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-11 20:26:34 +0200 |
commit | cfc3023cb6ce5aaec13f49bc4b821feb05e3fb03 (patch) | |
tree | da16e23aca547d7eb0cf4c4026415fad30d5b00f /src/vim9compile.c | |
parent | af8ea0d066d31cf3cd0a39c5c49ce0342728588d (diff) | |
download | vim-git-cfc3023cb6ce5aaec13f49bc4b821feb05e3fb03.tar.gz |
patch 8.2.2756: Vim9: blob index and slice not implemented yetv8.2.2756
Problem: Vim9: blob index and slice not implemented yet.
Solution: Implement blob index and slice.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index 59d133907..926365964 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2725,8 +2725,18 @@ compile_member(int is_slice, cctx_T *cctx) } else if (vtype == VAR_BLOB) { - emsg("Sorry, blob index and slice not implemented yet"); - return FAIL; + if (is_slice) + { + *typep = &t_blob; + if (generate_instr_drop(cctx, ISN_BLOBSLICE, 2) == FAIL) + return FAIL; + } + else + { + *typep = &t_number; + if (generate_instr_drop(cctx, ISN_BLOBINDEX, 1) == FAIL) + return FAIL; + } } else if (vtype == VAR_LIST || *typep == &t_any) { @@ -4088,7 +4098,7 @@ compile_subscript( // list index: list[123] // dict member: dict[key] // string index: text[123] - // TODO: blob index + // blob index: blob[123] // TODO: more arguments // TODO: recognize list or dict at runtime if (generate_ppconst(cctx, ppconst) == FAIL) @@ -9241,6 +9251,8 @@ delete_instr(isn_T *isn) case ISN_ANYSLICE: case ISN_BCALL: case ISN_BLOBAPPEND: + case ISN_BLOBINDEX: + case ISN_BLOBSLICE: case ISN_CATCH: case ISN_CHECKLEN: case ISN_CHECKNR: |