summaryrefslogtreecommitdiff
path: root/server/src/vm/global.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-31 16:20:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-31 16:20:08 +0800
commita692d7b413e4aff34a2a714cc6aec9ad0b495b33 (patch)
tree67b7897759009cef7b82963a529c580878ffd91c /server/src/vm/global.lua
parent8d29cb3148ff2a6a05b879171c79b65cc21cf3d9 (diff)
downloadlua-language-server-a692d7b413e4aff34a2a714cc6aec9ad0b495b33.zip
整理代码
Diffstat (limited to 'server/src/vm/global.lua')
-rw-r--r--server/src/vm/global.lua20
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