diff options
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/function.lua | 12 | ||||
-rw-r--r-- | server/src/vm/source.lua | 2 | ||||
-rw-r--r-- | server/src/vm/value.lua | 3 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 11 |
4 files changed, 18 insertions, 10 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 2fe1ee41..c6915f25 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -3,6 +3,8 @@ local valueMgr = require 'vm.value' local localMgr = require 'vm.local' local sourceMgr = require 'vm.source' +local Id = 0 +local List = {} local Watch = setmetatable({}, {__mode = 'kv'}) local mt = {} @@ -296,7 +298,11 @@ function mt:getSource() end function mt:kill() + if self._removed then + return + end self._removed = true + List[self.id] = nil end local function create(source) @@ -307,19 +313,23 @@ local function create(source) if not id then error('Not instanted source') end + Id = Id + 1 local self = setmetatable({ source = id, + id = id, locals = {}, finishs = {}, args = {}, argValues = {}, }, mt) self:push(source) - Watch[self] = true + Watch[self] = id + List[id] = self return self end return { create = create, watch = Watch, + list = List, } diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua index b74d10d2..af8b9ab3 100644 --- a/server/src/vm/source.lua +++ b/server/src/vm/source.lua @@ -103,7 +103,7 @@ local function instant(source) Id = Id + 1 source.id = Id List[Id] = source - Watch[source] = Id + Watch[source] = Id setmetatable(source, mt) return true end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index a7170659..ad1deccf 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -389,6 +389,9 @@ function mt:getFunction() if not func then return nil end + if func._removed then + return nil + end if not func:getSource() then self._func = nil end diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 4b044916..77f428ae 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -637,14 +637,6 @@ function mt:getUnary(exp) end function mt:getExp(exp) - if coroutine.isyieldable() then - if self.lsp:isNeedCompile(self.uri) then - coroutine.yield() - else - self:remove() - coroutine.yield('stop') - end - end self:instantSource(exp) local tp = exp.type if tp == 'nil' then @@ -1129,6 +1121,9 @@ function mt:createEnvironment(ast) end function mt:eachSource(callback) + if self._removed then + return + end local sources = self.sources for i = 1, #sources do callback(sources[i]) |