summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-15 14:47:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-15 14:47:30 +0800
commitfe08a9909c1549cd3e0b19e5c773078a70044420 (patch)
treedddc37be7fc1d76d93e3defe6c7741af880ffe82
parent6efd53aed4ab9eb413df1ba3f6cc8ae65c7aaca5 (diff)
downloadlua-language-server-fe08a9909c1549cd3e0b19e5c773078a70044420.zip
全局变量初始化没必要用个马甲value
-rw-r--r--server/src/vm/global.lua17
1 files changed, 7 insertions, 10 deletions
diff --git a/server/src/vm/global.lua b/server/src/vm/global.lua
index b1b32505..dea30525 100644
--- a/server/src/vm/global.lua
+++ b/server/src/vm/global.lua
@@ -6,21 +6,18 @@ local sourceMgr = require 'vm.source'
return function (lsp)
local global = lsp and lsp.globalValue
if not global then
- global = createValue('table', sourceMgr.dummy())
+ local t = {}
for name, lib in pairs(library.global) do
- if not global:rawGet(name) then
- local value = libraryBuilder.value(lib)
- global:rawSet(name, value)
- end
+ t[name] = libraryBuilder.value(lib)
end
- local _G = global:getChild '_G'
- global:eachChild(function (k, v)
- _G:setChild(k, v)
- end)
+ global = t._G
+ for k, v in pairs(t) do
+ global:setChild(k, v)
+ end
end
if lsp then
lsp.globalValue = global
end
- return global:rawGet('_G')
+ return global
end