diff options
author | unknown <sumnekosun@intranet.123u.com> | 2019-04-02 17:09:56 +0800 |
---|---|---|
committer | unknown <sumnekosun@intranet.123u.com> | 2019-04-02 17:09:56 +0800 |
commit | d283727cffff43312e5129801e265c2957d507d6 (patch) | |
tree | 93333303de1715e6c2754213d6721bdcfcf73a22 /server/src/vm | |
parent | 43e0d5819011e069893ee9f05eba2fc90d1b4bf5 (diff) | |
download | lua-language-server-d283727cffff43312e5129801e265c2957d507d6.zip |
函数重新从全局查找
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/source.lua | 54 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 2 |
2 files changed, 51 insertions, 5 deletions
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua index c364d9cf..ce1d325b 100644 --- a/server/src/vm/source.lua +++ b/server/src/vm/source.lua @@ -48,12 +48,11 @@ function mt:bindValue(value, action) end end -function mt:bindCall(func, args) - if func then - self._bindCall = func +function mt:bindCall(args) + if args then self._bindCallArgs = args else - return self._bindCall, self._bindCallArgs + return self._bindCallArgs end end @@ -96,6 +95,53 @@ function mt:isDead() return self._dead end +function mt:findValue() + local value = self:bindValue() + if not value then + return nil + end + if not value:isGlobal() then + return value + end + if self.type ~= 'name' then + return value + end + local parent = self:get 'parent' + if not parent then + return value + end + local name = self[1] + if type(name) ~= 'string' then + return value + end + return parent:getChild(name) or value +end + +function mt:findCallFunction() + local simple = self:get 'simple' + if not simple then + return nil + end + local source + for i = 1, #simple do + if simple[i] == self then + source = simple[i-1] + end + end + if not source then + return nil + end + local value = source:bindValue() + if value and value:getFunction() then + return value + end + value = source:findValue() + if value and value:getFunction() then + return value + end + return nil +end + local function instant(source) if source.id then return false diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 5d6b024f..a26fe808 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -462,7 +462,7 @@ function mt:getSimple(simple, max) table.insert(args, 1, simple[i-3]) end object = nil - source:bindCall(func, args) + source:bindCall(args) value = self:call(func, values, source) or valueMgr.create('any', self:getDefaultSource()) elseif source.type == 'index' then local child = source[1] |