diff options
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 |