From 4f0379c5cadd79df2e5bc593198b5464aeeb982e 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, 30 Jan 2019 09:35:11 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B=E6=8E=A8=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/value.lua | 2 +- server/src/core/vm.lua | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'server/src') diff --git a/server/src/core/value.lua b/server/src/core/value.lua index 05248d0d..a998d195 100644 --- a/server/src/core/value.lua +++ b/server/src/core/value.lua @@ -19,7 +19,7 @@ function mt:inference(tp, rate) if not tp then tp = 'nil' end - if tp == 'any' then + if tp == 'any' or tp == 'nil' then rate = 0.0 end if not self._type then diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua index b88ae1ab..0a2a773c 100644 --- a/server/src/core/vm.lua +++ b/server/src/core/vm.lua @@ -919,13 +919,15 @@ function mt:getSimple(simple, mode) local obj = simple[i] local tp = obj.type obj.uri = self.uri + value = self:selectList(value, 1) if tp == 'call' then + value:inference('function', 0.9) local args = self:unpackList(obj) if object then table.insert(args, 1, self:getValue(object)) end - local func = self:selectList(value, 1) + local func = value -- 函数的返回值一定是list value = self:call(func, args, obj) if i < #simple then @@ -939,6 +941,8 @@ function mt:getSimple(simple, mode) } parentName = parentName .. '(...)' elseif tp == 'index' then + value:inference('table', 0.8) + value:inference('string', 0.2) local child = obj[1] obj.indexName = parentName local index = self:getIndex(child) @@ -961,6 +965,8 @@ function mt:getSimple(simple, mode) parentName = ('%s[?]'):format(parentName) end elseif tp == 'name' then + value:inference('table', 0.8) + value:inference('string', 0.2) if mode == 'value' or i < #simple then field = self:getField(value, obj[1], obj) or self:createField(value, obj[1], obj) field.parentValue = value @@ -977,10 +983,14 @@ function mt:getSimple(simple, mode) obj.parentName = parentName parentName = parentName .. '.' .. field.key elseif tp == ':' then + value:inference('table', 0.8) + value:inference('string', 0.2) object = field simple[i-1].colon = obj colon = colon elseif tp == '.' then + value:inference('table', 0.8) + value:inference('string', 0.2) simple[i-1].dot = obj end end -- cgit v1.2.3