From 70075c6b951b5af948ff7f3550d136a9863ebf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 23 Jan 2019 17:10:41 +0800 Subject: =?UTF-8?q?=E6=B2=A1=E5=BF=85=E8=A6=81=E7=94=A8readOnly=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E5=9B=A0=E4=B8=BA=E4=B8=80=E5=AE=9A=E4=BC=9A=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E7=BC=96=E8=AF=91=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/global.lua | 17 ++++++++++------- server/src/core/vm.lua | 15 +++++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'server/src') diff --git a/server/src/core/global.lua b/server/src/core/global.lua index 9dca50d0..655bc1c4 100644 --- a/server/src/core/global.lua +++ b/server/src/core/global.lua @@ -26,19 +26,22 @@ end function mt:compileVM(uri, vm) local seted = {} - for k, v in pairs(vm.results.globals) do - seted[k] = true - self:markSet(uri, k, v) + local fixed = {} + for _, data in ipairs(vm.results.globals) do + local key = data.global.key + fixed[key] = true + if data.type == 'global' then + seted[key] = true + self:markSet(uri, key, data.global) + end end for k in next, vm.env.child do - if not seted[k] then - self:markGet(uri, k) - end + self:markGet(uri, k) end local needReCompile = {} for otherUri, gets in pairs(self.get) do - for key in pairs(seted) do + for key in pairs(fixed) do if gets[key] ~= nil then needReCompile[#needReCompile+1] = otherUri goto CONTINUE diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua index a851f859..2f2a5dbf 100644 --- a/server/src/core/vm.lua +++ b/server/src/core/vm.lua @@ -379,10 +379,7 @@ function mt:getField(pValue, name, source) local field = (pValue.child and pValue.child[name]) if not field and pValue.ENV then if self.lsp then - local g = self.lsp:getGlobal(name) - if g then - field = readOnly(g) - end + field = self.lsp:getGlobal(name) end end if not field then @@ -1293,7 +1290,10 @@ function mt:doSet(action) local var = self:getName(key[1], key) self:setValue(var, value, key) if self:isGlobal(var) then - self.results.globals[key[1]] = var + self.results.globals[#self.results.globals+1] = { + type = 'global', + global = var, + } end elseif key.type == 'simple' then local field = self:getSimple(key, 'field') @@ -1301,7 +1301,10 @@ function mt:doSet(action) local var = field repeat if self:isGlobal(var) then - self.results.globals[var.key] = var + self.results.globals[#self.results.globals+1] = { + type = 'field', + global = var, + } break end var = var.parent -- cgit v1.2.3