diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-31 16:20:08 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-31 16:20:08 +0800 |
commit | a692d7b413e4aff34a2a714cc6aec9ad0b495b33 (patch) | |
tree | 67b7897759009cef7b82963a529c580878ffd91c /server/src/vm/global.lua | |
parent | 8d29cb3148ff2a6a05b879171c79b65cc21cf3d9 (diff) | |
download | lua-language-server-a692d7b413e4aff34a2a714cc6aec9ad0b495b33.zip |
整理代码
Diffstat (limited to 'server/src/vm/global.lua')
-rw-r--r-- | server/src/vm/global.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/server/src/vm/global.lua b/server/src/vm/global.lua new file mode 100644 index 00000000..4e368641 --- /dev/null +++ b/server/src/vm/global.lua @@ -0,0 +1,20 @@ +local createValue = require 'vm.value' +local library = require 'core.library' +local libraryBuilder = require 'vm.library' + +return function (lsp) + local global = lsp and lsp.globalValue + if not global then + global = createValue('table') + end + for name, lib in pairs(library.global) do + if not global:rawGet(name) then + local value = libraryBuilder.value(lib) + global:rawSet(name, value) + end + end + if lsp then + lsp.globalValue = global + end + return global +end |