comparison src/vim9compile.c @ 23334:4b4f695e9cd1 v8.2.2210

patch 8.2.2210: Vim9: allocating a type to set TTFLAG_BOOL_OK Commit: https://github.com/vim/vim/commit/3868f59466ed5ff1c5624f40b93c0034ce62cb82 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 25 13:20:41 2020 +0100 patch 8.2.2210: Vim9: allocating a type to set TTFLAG_BOOL_OK Problem: Vim9: allocating a type to set TTFLAG_BOOL_OK. Solution: Add t_number_bool.
author Bram Moolenaar <Bram@vim.org>
date Fri, 25 Dec 2020 13:30:03 +0100
parents cdb706d5c43d
children 1f37fd20f851
comparison
equal deleted inserted replaced
23333:f7d4e8035eb3 23334:4b4f695e9cd1
929 if ((isn = generate_instr_type(cctx, ISN_PUSHNR, &t_number)) == NULL) 929 if ((isn = generate_instr_type(cctx, ISN_PUSHNR, &t_number)) == NULL)
930 return FAIL; 930 return FAIL;
931 isn->isn_arg.number = number; 931 isn->isn_arg.number = number;
932 932
933 if (number == 0 || number == 1) 933 if (number == 0 || number == 1)
934 {
935 type_T *type = get_type_ptr(cctx->ctx_type_list);
936
937 // A 0 or 1 number can also be used as a bool. 934 // A 0 or 1 number can also be used as a bool.
938 if (type != NULL) 935 ((type_T **)stack->ga_data)[stack->ga_len - 1] = &t_number_bool;
939 {
940 type->tt_type = VAR_NUMBER;
941 type->tt_flags = TTFLAG_BOOL_OK;
942 ((type_T **)stack->ga_data)[stack->ga_len - 1] = type;
943 }
944 }
945 return OK; 936 return OK;
946 } 937 }
947 938
948 /* 939 /*
949 * Generate an ISN_PUSHBOOL instruction. 940 * Generate an ISN_PUSHBOOL instruction.