diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/vm/function.lua | 2 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 8 |
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) |