diff options
-rw-r--r-- | server/src/service.lua | 12 | ||||
-rw-r--r-- | server/src/vm/local.lua | 3 | ||||
-rw-r--r-- | server/src/vm/source.lua | 3 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 2 |
4 files changed, 13 insertions, 7 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 1c102bfa..cb6a20a9 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -216,6 +216,7 @@ function mt:reCompile() n = n + 1 end log.debug('reCompile:', n) + self:_testMemory() end function mt:loadVM(uri) @@ -541,10 +542,6 @@ function mt:_loadProto() end function mt:_testMemory() - if os.clock() - self._clock < 60 then - return - end - self._clock = os.clock() local cachedVM = 0 local cachedSource = 0 for _, obj in pairs(self._file) do @@ -565,7 +562,7 @@ function mt:_testMemory() local alivedSource = 0 local deadSource = 0 - for _, id in pairs(source.watch) do + for src, id in pairs(source.watch) do if source.list[id] then alivedSource = alivedSource + 1 else @@ -595,7 +592,10 @@ end function mt:onTick() self:_loadProto() self:_doCompileTask() - self:_testMemory() + if os.clock() - self._clock >= 60 then + self._clock = os.clock() + self:_testMemory() + end end function mt:listen() diff --git a/server/src/vm/local.lua b/server/src/vm/local.lua index cada88af..f5e65e83 100644 --- a/server/src/vm/local.lua +++ b/server/src/vm/local.lua @@ -124,6 +124,9 @@ end function mt:close(pos) if pos then + if pos <= 0 then + pos = math.maxinteger + end self._close = pos else return self._close diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua index 810db769..365c2757 100644 --- a/server/src/vm/source.lua +++ b/server/src/vm/source.lua @@ -1,6 +1,9 @@ local mt = {} mt.__index = mt mt.uri = '' +mt.start = 0 +mt.finish = 0 +mt.id = 0 local Id = 0 local List = {} diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index ef939c79..4aa3fd3c 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -1138,7 +1138,7 @@ function mt:createEnvironment(ast) -- 全局变量`_G` local global = buildGlobal(self.lsp) -- 隐藏的上值`_ENV` - local env = self:createLocal('_ENV', sourceMgr.dummy(), global) + local env = self:createLocal('_ENV', self:getDefaultSource(), global) env:set('hide', true) self.env = env end |