From 357564062f18bfd5eedad002fa55ff93db10833a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 27 Mar 2019 14:27:47 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=A4=84=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/vm/function.lua | 2 +- server/src/vm/vm.lua | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'server/src') 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) -- cgit v1.2.3