summaryrefslogtreecommitdiff
path: root/server/src/vm/source.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-13 17:18:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-13 17:18:32 +0800
commit628a272b7babbeab995cf582ff4337b897ac09e6 (patch)
treede859adf802e7ea941cf990007e40d98a1fee77b /server/src/vm/source.lua
parent42ec4d53d770a053c0909f14b5aa7c8cd42bbcdb (diff)
downloadlua-language-server-628a272b7babbeab995cf582ff4337b897ac09e6.zip
解除value->info->source的循环引用
Diffstat (limited to 'server/src/vm/source.lua')
-rw-r--r--server/src/vm/source.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua
index d53019c7..8f65da8b 100644
--- a/server/src/vm/source.lua
+++ b/server/src/vm/source.lua
@@ -1,6 +1,8 @@
local mt = {}
mt.__index = mt
-mt._hasInstant = true
+
+local Id = 0
+local List = {}
function mt:bindLocal(loc, action)
if loc then
@@ -87,16 +89,25 @@ function mt:kill()
self._bindCall = nil
self._bindFunction = nil
self._bindCallArgs = nil
+ List[self.id] = nil
end
function mt:isDead()
return self._dead
end
-return function (vm, source)
- if source._hasInstant then
+local function instant(vm, source)
+ if source.id then
return false
end
+ Id = Id + 1
+ source.id = Id
+ List[Id] = source
setmetatable(source, mt)
return true
end
+
+return {
+ instant = instant,
+ list = List,
+}