Mercurial > vim
comparison src/vim9compile.c @ 19461:08ef11a81daa v8.2.0288
patch 8.2.0288: Vim9: some float and blob operators not tested
Commit: https://github.com/vim/vim/commit/0062c2d4f91caa2360933068ac46c55bdd303b53
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 20 22:14:31 2020 +0100
patch 8.2.0288: Vim9: some float and blob operators not tested
Problem: Vim9: some float and blob operators not tested.
Solution: Add float and blob tests. Fix addition.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Feb 2020 22:30:03 +0100 |
parents | 655631882288 |
children | f41e46f02c8c |
comparison
equal
deleted
inserted
replaced
19460:5a60f7d281e8 | 19461:08ef11a81daa |
---|---|
372 vartype = type1->tt_type; | 372 vartype = type1->tt_type; |
373 | 373 |
374 switch (*op) | 374 switch (*op) |
375 { | 375 { |
376 case '+': if (vartype != VAR_LIST && vartype != VAR_BLOB | 376 case '+': if (vartype != VAR_LIST && vartype != VAR_BLOB |
377 && type1->tt_type != VAR_UNKNOWN | |
378 && type2->tt_type != VAR_UNKNOWN | |
377 && check_number_or_float( | 379 && check_number_or_float( |
378 type1->tt_type, type2->tt_type, op) == FAIL) | 380 type1->tt_type, type2->tt_type, op) == FAIL) |
379 return FAIL; | 381 return FAIL; |
380 isn = generate_instr_drop(cctx, | 382 isn = generate_instr_drop(cctx, |
381 vartype == VAR_NUMBER ? ISN_OPNR | 383 vartype == VAR_NUMBER ? ISN_OPNR |
1072 | 1074 |
1073 if ((isn = generate_instr(cctx, ISN_MEMBER)) == NULL) | 1075 if ((isn = generate_instr(cctx, ISN_MEMBER)) == NULL) |
1074 return FAIL; | 1076 return FAIL; |
1075 isn->isn_arg.string = vim_strnsave(name, (int)len); | 1077 isn->isn_arg.string = vim_strnsave(name, (int)len); |
1076 | 1078 |
1079 // check for dict type | |
1080 type = ((type_T **)stack->ga_data)[stack->ga_len - 1]; | |
1081 if (type->tt_type != VAR_DICT && type != &t_any) | |
1082 { | |
1083 emsg(_(e_dictreq)); | |
1084 return FAIL; | |
1085 } | |
1077 // change dict type to dict member type | 1086 // change dict type to dict member type |
1078 type = ((type_T **)stack->ga_data)[stack->ga_len - 1]; | 1087 if (type->tt_type == VAR_DICT) |
1079 ((type_T **)stack->ga_data)[stack->ga_len - 1] = type->tt_member; | 1088 ((type_T **)stack->ga_data)[stack->ga_len - 1] = type->tt_member; |
1080 | 1089 |
1081 return OK; | 1090 return OK; |
1082 } | 1091 } |
1083 | 1092 |
1084 /* | 1093 /* |
2368 if ((*typep)->tt_type != VAR_LIST && *typep != &t_any) | 2377 if ((*typep)->tt_type != VAR_LIST && *typep != &t_any) |
2369 { | 2378 { |
2370 emsg(_(e_listreq)); | 2379 emsg(_(e_listreq)); |
2371 return FAIL; | 2380 return FAIL; |
2372 } | 2381 } |
2373 *typep = (*typep)->tt_member; | 2382 if ((*typep)->tt_type == VAR_LIST) |
2383 *typep = (*typep)->tt_member; | |
2374 } | 2384 } |
2375 else if (**arg == '.' && (*arg)[1] != '.') | 2385 else if (**arg == '.' && (*arg)[1] != '.') |
2376 { | 2386 { |
2377 char_u *p; | 2387 char_u *p; |
2378 | 2388 |
2385 if (p == *arg) | 2395 if (p == *arg) |
2386 { | 2396 { |
2387 semsg(_(e_syntax_at), *arg); | 2397 semsg(_(e_syntax_at), *arg); |
2388 return FAIL; | 2398 return FAIL; |
2389 } | 2399 } |
2390 // TODO: check type is dict | |
2391 if (generate_MEMBER(cctx, *arg, p - *arg) == FAIL) | 2400 if (generate_MEMBER(cctx, *arg, p - *arg) == FAIL) |
2392 return FAIL; | 2401 return FAIL; |
2393 *arg = p; | 2402 *arg = p; |
2394 } | 2403 } |
2395 else | 2404 else |
4962 line = compile_echo(p, FALSE, &cctx); | 4971 line = compile_echo(p, FALSE, &cctx); |
4963 break; | 4972 break; |
4964 | 4973 |
4965 default: | 4974 default: |
4966 // Not recognized, execute with do_cmdline_cmd(). | 4975 // Not recognized, execute with do_cmdline_cmd(). |
4976 // TODO: | |
4977 // CMD_echomsg | |
4978 // CMD_execute | |
4979 // etc. | |
4967 generate_EXEC(&cctx, line); | 4980 generate_EXEC(&cctx, line); |
4968 line = (char_u *)""; | 4981 line = (char_u *)""; |
4969 break; | 4982 break; |
4970 } | 4983 } |
4971 if (line == NULL) | 4984 if (line == NULL) |