diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-15 16:14:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-15 16:14:28 +0800 |
commit | 5822e5ad4b7ae4d0bd1867323527bb419ed09d37 (patch) | |
tree | cf60c975f1bc3a889f3a869f99f807e77813858b /server/src | |
parent | 785d3e5963f793de712a96c88db08c684cb26bfc (diff) | |
download | lua-language-server-5822e5ad4b7ae4d0bd1867323527bb419ed09d37.zip |
修正一个bug
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/service.lua | 18 | ||||
-rw-r--r-- | server/src/vm/value.lua | 25 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 4 |
3 files changed, 24 insertions, 23 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 5deae2bb..0edfe935 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -565,15 +565,15 @@ function mt:onTick() )) --TODO source测试 - local total = 0 - local alive = 0 - for source in pairs(CachedSource) do - if not source:isDead() then - alive = alive + 1 - end - total = total + 1 - end - log.debug(('CachedSource: %d/%d'):format(alive, total)) + --local total = 0 + --local alive = 0 + --for source in pairs(CachedSource) do + -- if not source:isDead() then + -- alive = alive + 1 + -- end + -- total = total + 1 + --end + --log.debug(('CachedSource: %d/%d'):format(alive, total)) end end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 84012b25..a2e6ba05 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -140,7 +140,17 @@ function mt:eachLibChild(callback) end end -function mt:getChild(index, source, mark) +function mt:getChild(index, source) + local value = self:_getChild(index) + if not value then + value = create('any', source) + self:setChild(index, value) + value.uri = self.uri + end + return value +end + +function mt:_getChild(index, source, mark) self:setType('table', 0.5) local value = self:rawGet(index) if value then @@ -149,25 +159,16 @@ function mt:getChild(index, source, mark) local method = self:getMetaMethod('__index') if not method then local v = self:getLibChild(index) - if v then - return v - end - v = create('any', source) - self:setChild(index, v) - v.uri = self.uri return v end if not mark then mark = {} end if mark[method] then - local v = create('any', source) - self:setChild(index, v) - v.uri = self.uri - return v + return nil end mark[method] = true - return method:getChild(index, source, mark) + return method:_getChild(index, source, mark) end function mt:bindChild(other) diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 555154b3..4435d7d5 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -9,7 +9,7 @@ local createMulti = require 'vm.multi' local libraryBuilder = require 'vm.library' -- TODO source测试 -rawset(_G, 'CachedSource', setmetatable({}, { __mode = 'kv' })) +--rawset(_G, 'CachedSource', setmetatable({}, { __mode = 'kv' })) local mt = {} mt.__index = mt @@ -1084,7 +1084,7 @@ function mt:instantSource(source) if sourceMgr.instant(source) then source:setUri(self:getUri()) self.sources[#self.sources+1] = source - CachedSource[source] = true + --CachedSource[source] = true end return source end |