Mercurial > vim
comparison src/vim9compile.c @ 21232:3f14e0d4a4dd v8.2.1167
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Commit: https://github.com/vim/vim/commit/389df259c49d1ca4f7aa129b702f6083985b1e73
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 9 21:20:47 2020 +0200
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Problem: Vim9: builtin function method call only supports first argument.
Solution: Shift arguments when needed. (closes https://github.com/vim/vim/issues/6305, closes https://github.com/vim/vim/issues/6419)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 09 Jul 2020 21:30:03 +0200 |
parents | ad13736a1783 |
children | 4edc60c9c0aa |
comparison
equal
deleted
inserted
replaced
21231:fcc215b37837 | 21232:3f14e0d4a4dd |
---|---|
1443 return OK; | 1443 return OK; |
1444 } | 1444 } |
1445 | 1445 |
1446 /* | 1446 /* |
1447 * Generate an ISN_BCALL instruction. | 1447 * Generate an ISN_BCALL instruction. |
1448 * "method_call" is TRUE for "value->method()" | |
1448 * Return FAIL if the number of arguments is wrong. | 1449 * Return FAIL if the number of arguments is wrong. |
1449 */ | 1450 */ |
1450 static int | 1451 static int |
1451 generate_BCALL(cctx_T *cctx, int func_idx, int argcount) | 1452 generate_BCALL(cctx_T *cctx, int func_idx, int argcount, int method_call) |
1452 { | 1453 { |
1453 isn_T *isn; | 1454 isn_T *isn; |
1454 garray_T *stack = &cctx->ctx_type_stack; | 1455 garray_T *stack = &cctx->ctx_type_stack; |
1456 int argoff; | |
1455 type_T *argtypes[MAX_FUNC_ARGS]; | 1457 type_T *argtypes[MAX_FUNC_ARGS]; |
1456 int i; | 1458 int i; |
1457 | 1459 |
1458 RETURN_OK_IF_SKIP(cctx); | 1460 RETURN_OK_IF_SKIP(cctx); |
1459 if (check_internal_func(func_idx, argcount) == FAIL) | 1461 argoff = check_internal_func(func_idx, argcount); |
1460 return FAIL; | 1462 if (argoff < 0) |
1463 return FAIL; | |
1464 | |
1465 if (method_call && argoff > 1) | |
1466 { | |
1467 if ((isn = generate_instr(cctx, ISN_SHUFFLE)) == NULL) | |
1468 return FAIL; | |
1469 isn->isn_arg.shuffle.shfl_item = argcount; | |
1470 isn->isn_arg.shuffle.shfl_up = argoff - 1; | |
1471 } | |
1461 | 1472 |
1462 if ((isn = generate_instr(cctx, ISN_BCALL)) == NULL) | 1473 if ((isn = generate_instr(cctx, ISN_BCALL)) == NULL) |
1463 return FAIL; | 1474 return FAIL; |
1464 isn->isn_arg.bfunc.cbf_idx = func_idx; | 1475 isn->isn_arg.bfunc.cbf_idx = func_idx; |
1465 isn->isn_arg.bfunc.cbf_argcount = argcount; | 1476 isn->isn_arg.bfunc.cbf_argcount = argcount; |
2928 int idx; | 2939 int idx; |
2929 | 2940 |
2930 // builtin function | 2941 // builtin function |
2931 idx = find_internal_func(name); | 2942 idx = find_internal_func(name); |
2932 if (idx >= 0) | 2943 if (idx >= 0) |
2933 res = generate_BCALL(cctx, idx, argcount); | 2944 res = generate_BCALL(cctx, idx, argcount, argcount_init == 1); |
2934 else | 2945 else |
2935 semsg(_(e_unknownfunc), namebuf); | 2946 semsg(_(e_unknownfunc), namebuf); |
2936 goto theend; | 2947 goto theend; |
2937 } | 2948 } |
2938 | 2949 |
7395 case ISN_COMPARENR: | 7406 case ISN_COMPARENR: |
7396 case ISN_COMPARESPECIAL: | 7407 case ISN_COMPARESPECIAL: |
7397 case ISN_COMPARESTRING: | 7408 case ISN_COMPARESTRING: |
7398 case ISN_CONCAT: | 7409 case ISN_CONCAT: |
7399 case ISN_DCALL: | 7410 case ISN_DCALL: |
7411 case ISN_SHUFFLE: | |
7400 case ISN_DROP: | 7412 case ISN_DROP: |
7401 case ISN_ECHO: | 7413 case ISN_ECHO: |
7402 case ISN_ECHOERR: | 7414 case ISN_ECHOERR: |
7403 case ISN_ECHOMSG: | 7415 case ISN_ECHOMSG: |
7404 case ISN_ENDTRY: | 7416 case ISN_ENDTRY: |