Mercurial > vim
comparison src/vim9compile.c @ 19330:9c8b803fe598 v8.2.0223
patch 8.2.0223: some instructions not yet tested
Commit: https://github.com/vim/vim/commit/5cab73f8cca46d831fb9337b176493da2a55ed5d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 6 19:25:19 2020 +0100
patch 8.2.0223: some instructions not yet tested
Problem: Some instructions not yet tested.
Solution: Disassemble more instructions. Move tests to a new file. Compile
call to s:function().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Feb 2020 19:30:08 +0100 |
parents | e99e6d794597 |
children | d6e8a9e80be4 |
comparison
equal
deleted
inserted
replaced
19329:f49020e6bf12 | 19330:9c8b803fe598 |
---|---|
1684 { | 1684 { |
1685 char_u *name = *arg; | 1685 char_u *name = *arg; |
1686 char_u *p; | 1686 char_u *p; |
1687 int argcount = argcount_init; | 1687 int argcount = argcount_init; |
1688 char_u namebuf[100]; | 1688 char_u namebuf[100]; |
1689 char_u fname_buf[FLEN_FIXED + 1]; | |
1690 char_u *tofree = NULL; | |
1691 int error = FCERR_NONE; | |
1689 ufunc_T *ufunc; | 1692 ufunc_T *ufunc; |
1693 int res = FAIL; | |
1690 | 1694 |
1691 if (varlen >= sizeof(namebuf)) | 1695 if (varlen >= sizeof(namebuf)) |
1692 { | 1696 { |
1693 semsg(_("E1011: name too long: %s"), name); | 1697 semsg(_("E1011: name too long: %s"), name); |
1694 return FAIL; | 1698 return FAIL; |
1695 } | 1699 } |
1696 vim_strncpy(namebuf, name, varlen); | 1700 vim_strncpy(namebuf, *arg, varlen); |
1701 name = fname_trans_sid(namebuf, fname_buf, &tofree, &error); | |
1697 | 1702 |
1698 *arg = skipwhite(*arg + varlen + 1); | 1703 *arg = skipwhite(*arg + varlen + 1); |
1699 if (compile_arguments(arg, cctx, &argcount) == FAIL) | 1704 if (compile_arguments(arg, cctx, &argcount) == FAIL) |
1700 return FAIL; | 1705 goto theend; |
1701 | 1706 |
1702 if (ASCII_ISLOWER(*name)) | 1707 if (ASCII_ISLOWER(*name) && name[1] != ':') |
1703 { | 1708 { |
1704 int idx; | 1709 int idx; |
1705 | 1710 |
1706 // builtin function | 1711 // builtin function |
1707 idx = find_internal_func(namebuf); | 1712 idx = find_internal_func(name); |
1708 if (idx >= 0) | 1713 if (idx >= 0) |
1709 return generate_BCALL(cctx, idx, argcount); | 1714 { |
1715 res = generate_BCALL(cctx, idx, argcount); | |
1716 goto theend; | |
1717 } | |
1710 semsg(_(e_unknownfunc), namebuf); | 1718 semsg(_(e_unknownfunc), namebuf); |
1711 } | 1719 } |
1712 | 1720 |
1713 // User defined function or variable must start with upper case. | |
1714 if (!ASCII_ISUPPER(*name)) | |
1715 { | |
1716 semsg(_("E1012: Invalid function name: %s"), namebuf); | |
1717 return FAIL; | |
1718 } | |
1719 | |
1720 // If we can find the function by name generate the right call. | 1721 // If we can find the function by name generate the right call. |
1721 ufunc = find_func(namebuf, cctx); | 1722 ufunc = find_func(name, cctx); |
1722 if (ufunc != NULL) | 1723 if (ufunc != NULL) |
1723 return generate_CALL(cctx, ufunc, argcount); | 1724 { |
1725 res = generate_CALL(cctx, ufunc, argcount); | |
1726 goto theend; | |
1727 } | |
1724 | 1728 |
1725 // If the name is a variable, load it and use PCALL. | 1729 // If the name is a variable, load it and use PCALL. |
1726 p = namebuf; | 1730 p = namebuf; |
1727 if (compile_load(&p, namebuf + varlen, cctx, FALSE) == OK) | 1731 if (compile_load(&p, namebuf + varlen, cctx, FALSE) == OK) |
1728 return generate_PCALL(cctx, argcount, FALSE); | 1732 { |
1733 res = generate_PCALL(cctx, argcount, FALSE); | |
1734 goto theend; | |
1735 } | |
1729 | 1736 |
1730 // The function may be defined only later. Need to figure out at runtime. | 1737 // The function may be defined only later. Need to figure out at runtime. |
1731 return generate_UCALL(cctx, namebuf, argcount); | 1738 res = generate_UCALL(cctx, name, argcount); |
1739 | |
1740 theend: | |
1741 vim_free(tofree); | |
1742 return res; | |
1732 } | 1743 } |
1733 | 1744 |
1734 // like NAMESPACE_CHAR but with 'a' and 'l'. | 1745 // like NAMESPACE_CHAR but with 'a' and 'l'. |
1735 #define VIM9_NAMESPACE_CHAR (char_u *)"bgstvw" | 1746 #define VIM9_NAMESPACE_CHAR (char_u *)"bgstvw" |
1736 | 1747 |