summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-12 18:12:44 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-12 18:12:44 +0800
commitfe7b7bd71785844dd34aea9e2a1da9f8b9e6620a (patch)
treea7abc0fef99dff8e2c3f5a6262a7cc6bf8f51829
parentc0c6f06e5d3df777790fb0f209d53f38e38c34db (diff)
downloadlua-language-server-fe7b7bd71785844dd34aea9e2a1da9f8b9e6620a.zip
显示一下vm的数量以供调试
-rw-r--r--server/src/vm/vm.lua17
-rw-r--r--server/test/example/vm.txt (renamed from server/test/example/vm.lua)0
-rw-r--r--server/test/full/example.lua2
3 files changed, 18 insertions, 1 deletions
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 841b09ca..88a272de 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -1171,6 +1171,22 @@ local function compile(ast, lsp, uri)
return vm
end
+-- TODO 测试代码
+local CachedVM = setmetatable({}, {__mode = 'kv'})
+
+local function checkCachedVM(vm)
+ CachedVM[vm] = true
+ local total = 0
+ local alive = 0
+ for vm in pairs(CachedVM) do
+ total = total + 1
+ if not vm:isRemoved() then
+ alive =alive + 1
+ end
+ end
+ log.debug(('持有的VM:%d/%d'):format(alive, total))
+end
+
return function (ast, lsp, uri)
if not ast then
return nil
@@ -1179,5 +1195,6 @@ return function (ast, lsp, uri)
if not suc then
return nil, res
end
+ checkCachedVM(res)
return res
end
diff --git a/server/test/example/vm.lua b/server/test/example/vm.txt
index f2f4144d..f2f4144d 100644
--- a/server/test/example/vm.lua
+++ b/server/test/example/vm.txt
diff --git a/server/test/full/example.lua b/server/test/full/example.lua
index 90eff536..cf23335c 100644
--- a/server/test/full/example.lua
+++ b/server/test/full/example.lua
@@ -13,4 +13,4 @@ local function testIfExit(path)
print('基准测试耗时:', os.clock() - clock)
end
end
-testIfExit(ROOT / 'test' / 'example' / 'vm.lua')
+testIfExit(ROOT / 'test' / 'example' / 'vm.txt')