diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-29 17:43:22 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-29 17:43:22 +0800 |
commit | 1ec748aaa45599cb4487105842a1ad4cb5e7a2b4 (patch) | |
tree | 739850bf957b55a4fb4ce6f355bcd85df17747cf /server/src/vm | |
parent | dc2dc8c3a842a945b48ac8241180a7b1c6eb82a9 (diff) | |
download | lua-language-server-1ec748aaa45599cb4487105842a1ad4cb5e7a2b4.zip |
修正泄露
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/source.lua | 8 | ||||
-rw-r--r-- | server/src/vm/value.lua | 17 |
2 files changed, 23 insertions, 2 deletions
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua index 59d5d66d..3884af20 100644 --- a/server/src/vm/source.lua +++ b/server/src/vm/source.lua @@ -64,6 +64,14 @@ function mt:bindCall(args) end end +function mt:bindMetatable(meta) + if meta then + self._bindMetatable = meta + else + return self._bindMetatable + end +end + function mt:action() return self._action end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index f731892b..29419966 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -192,11 +192,24 @@ function mt:getChild(index, source) end function mt:setMetaTable(metatable) - self._meta = metatable + local source = metatable:getSource() + if not source then + return + end + source:bindMetatable(metatable) + self._meta = metatable.source end function mt:getMetaTable() - return self._meta + if not self._meta then + return nil + end + local metaSource = listMgr.get(self._meta) + if not metaSource then + self._meta = nil + return nil + end + return metaSource:bindMetatable() end function mt:getMetaMethod(name) |