diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-06 23:49:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-07-06 23:49:28 +0800 |
commit | a19a1f4f077830014dd2d2c378988e7770be2be1 (patch) | |
tree | 137f0455d0648c425b96004a236c074f30ad1340 /script/vm | |
parent | 79cc877095745be377b9dd189ee5e38cf35a3c5e (diff) | |
download | lua-language-server-a19a1f4f077830014dd2d2c378988e7770be2be1.zip |
support `call`
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/compiler.lua | 6 | ||||
-rw-r--r-- | script/vm/operator.lua | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index a13f1e3a..a9cd50cd 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -1472,6 +1472,9 @@ local compilerSwitch = util.switch() if not node then return end + if node:isEmpty() then + node = vm.runOperator('call', vararg.node) or node + end vm.setNode(source, node) end if vararg.type == 'varargs' then @@ -1490,6 +1493,9 @@ local compilerSwitch = util.switch() if not node then return end + if node:isEmpty() then + node = vm.runOperator('call', source.node) or node + end vm.setNode(source, node) end) : case 'doc.type' diff --git a/script/vm/operator.lua b/script/vm/operator.lua index 35910f94..69340648 100644 --- a/script/vm/operator.lua +++ b/script/vm/operator.lua @@ -24,6 +24,9 @@ vm.BINARY_OP = { 'shr', 'concat', } +vm.OTHER_OP = { + 'call', +} local unaryMap = { ['-'] = 'unm', @@ -47,8 +50,13 @@ local binaryMap = { ['..'] = 'concat', } -vm.UNARY_MAP = util.revertMap(unaryMap) -vm.BINARY_MAP = util.revertMap(binaryMap) +local otherMap = { + ['()'] = 'call', +} + +vm.OP_UNARY_MAP = util.revertMap(unaryMap) +vm.OP_BINARY_MAP = util.revertMap(binaryMap) +vm.OP_OTHER_MAP = util.revertMap(otherMap) ---@param operators parser.object[] ---@param op string |