diff options
Diffstat (limited to 'script/vm/global.lua')
-rw-r--r-- | script/vm/global.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/script/vm/global.lua b/script/vm/global.lua new file mode 100644 index 00000000..af30ffdd --- /dev/null +++ b/script/vm/global.lua @@ -0,0 +1,25 @@ +local library = require 'core.library' +local libraryBuilder = require 'vm.library' +local sourceMgr = require 'vm.source' + +return function (lsp) + local global = lsp and lsp.globalValue + if not global then + libraryBuilder.clear() + local t = {} + for name, lib in pairs(library.global) do + t[name] = libraryBuilder.value(lib) + end + + global = t._G + global:markGlobal() + global:set('ENV', true) + for k, v in pairs(t) do + global:setChild(k, v, sourceMgr.dummy()) + end + end + if lsp then + lsp.globalValue = global + end + return global +end |