From fe08a9909c1549cd3e0b19e5c773078a70044420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 15 Mar 2019 14:47:30 +0800 Subject: =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=B2=A1=E5=BF=85=E8=A6=81=E7=94=A8=E4=B8=AA=E9=A9=AC?= =?UTF-8?q?=E7=94=B2value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/vm/global.lua | 17 +++++++---------- 1 file 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 -- cgit v1.2.3