From a19a1f4f077830014dd2d2c378988e7770be2be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 6 Jul 2022 23:49:28 +0800 Subject: support `call` --- script/vm/compiler.lua | 6 ++++++ script/vm/operator.lua | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'script/vm') 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 -- cgit v1.2.3