From 41a21bdfcc878177565557a42fca4cc324552455 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, 20 Nov 2019 17:50:45 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/vm/getValue.lua | 43 +++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/server-beta/src/vm/getValue.lua b/server-beta/src/vm/getValue.lua index d5db880b..fe056c92 100644 --- a/server-beta/src/vm/getValue.lua +++ b/server-beta/src/vm/getValue.lua @@ -12,11 +12,7 @@ local typeSort = { NIL = setmetatable({''}, { __tostring = function () return 'nil' end }) -local function merge(a, b) - local t = {} - for i = 1, #a do - t[#t+1] = a[i] - end +local function merge(t, b) for i = 1, #b do t[#t+1] = b[i] end @@ -438,7 +434,7 @@ local function checkCall(result, source) end end -local function checkNext(result, source) +local function checkNext(results, source) local next = source.next if not next then return @@ -449,38 +445,20 @@ local function checkNext(result, source) or next.type == 'setfield' or next.type == 'setindex' or next.type == 'setmethod' then - merge(result, 'table') + merge(results, 'table') end end -local function checkDef(result, source) +local function checkDef(results, source) vm.eachDef(source, function (info) local src = info.source local tp = vm.getValue(src) if tp then - merge(result, tp) + merge(results, tp) end end) end -local function typeInference(source) - local tp = checkLiteral(source) - or checkValue(source) - or checkUnary(source) - or checkBinary(source) - if tp then - return tp - end - - local result = {} - - checkCall(result, source) - checkNext(result, source) - checkDef(result, source) - - return dump(result) -end - local function getValue(source) local result = checkLiteral(source) if result then @@ -492,6 +470,17 @@ local function getValue(source) if results then return results end + + results = {} + checkDef(results, source) + --checkCall(results, source) + --checkNext(results, source) + + if #results == 0 then + return nil + end + + return results end function vm.checkTrue(source) -- cgit v1.2.3