summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-27 14:27:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-27 14:27:47 +0800
commit357564062f18bfd5eedad002fa55ff93db10833a (patch)
tree01c17d8e89087f017e02ca5105acf69ca6281c36 /server
parentde6c5c4a40f12b647c6d2e266c4f395cab5731cc (diff)
downloadlua-language-server-357564062f18bfd5eedad002fa55ff93db10833a.zip
修正一处泄漏
Diffstat (limited to 'server')
-rw-r--r--server/src/vm/function.lua2
-rw-r--r--server/src/vm/vm.lua8
2 files changed, 8 insertions, 2 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua
index fab90a06..cb437d9e 100644
--- a/server/src/vm/function.lua
+++ b/server/src/vm/function.lua
@@ -173,7 +173,7 @@ function mt:run(vm)
if self._runed == 1 then
-- 如果是面向对象形式的函数,创建隐藏的参数self
if self._objectSource then
- local loc = localMgr.create('self', self._objectSource, self._objectValue)
+ local loc = localMgr.create('self', vm:instantSource(self._objectSource), self._objectValue)
loc:set('hide', true)
self:saveLocal('self', loc)
self.args[#self.args+1] = loc
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 4ca7b64b..26fcc84a 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -18,7 +18,6 @@ function mt:getDefaultSource()
return self:instantSource {
start = 0,
finish = 0,
- uri = self:getUri(),
}
end
@@ -642,6 +641,7 @@ function mt:getExp(exp)
if self.lsp:isNeedCompile(self.uri) then
coroutine.yield()
else
+ self:remove()
coroutine.yield('stop')
end
end
@@ -961,6 +961,7 @@ function mt:doAction(action)
if self.lsp:isNeedCompile(self.uri) then
coroutine.yield()
else
+ self:remove()
coroutine.yield('stop')
end
end
@@ -1062,6 +1063,10 @@ function mt:getUri()
end
function mt:instantSource(source)
+ if self:isRemoved() then
+ error('dead vm')
+ return nil
+ end
if sourceMgr.instant(source) then
source:setUri(self:getUri())
self.sources[#self.sources+1] = source
@@ -1142,6 +1147,7 @@ function mt:remove()
for _, source in ipairs(self.sources) do
source:kill()
end
+ self.sources = nil
end
local function compile(ast, lsp, uri)