summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/global.lua9
-rw-r--r--server/src/service.lua16
-rw-r--r--server/src/vm/vm.lua8
3 files changed, 21 insertions, 12 deletions
diff --git a/server/src/core/global.lua b/server/src/core/global.lua
index 7be76818..007f0fd9 100644
--- a/server/src/core/global.lua
+++ b/server/src/core/global.lua
@@ -24,11 +24,6 @@ end
function mt:clearGlobal(uri)
self.set[uri] = nil
self.get[uri] = nil
- local globalValue = self.lsp.globalValue
- if not globalValue then
- return
- end
- globalValue:removeUri(uri)
end
function mt:getAllUris()
@@ -44,6 +39,10 @@ function mt:getAllUris()
return uris
end
+function mt:hasSetGlobal(uri)
+ return self.set[uri] ~= nil
+end
+
return function (lsp)
return setmetatable({
get = {},
diff --git a/server/src/service.lua b/server/src/service.lua
index 4141b172..0c533b35 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -296,12 +296,12 @@ function mt:_compileGlobal(compiled)
end
end
-function mt:_clearGlobal(uri, compiled)
+function mt:_clearGlobal(uri)
self.global:clearGlobal(uri)
- local uris = self.global:getAllUris()
- for _, uri in ipairs(uris) do
- self:needCompile(uri, compiled)
- end
+end
+
+function mt:_hasSetGlobal(uri)
+ return self.global:hasSetGlobal(uri)
end
function mt:compileVM(uri)
@@ -320,7 +320,7 @@ function mt:compileVM(uri)
local version = obj.version
obj.astCost = os.clock() - clock
self:_clearChainNode(obj, uri)
- --self:_clearGlobal(uri, compiled)
+ self:_clearGlobal(uri)
local clock = os.clock()
local vm = buildVM(ast, self, uri)
@@ -350,7 +350,9 @@ function mt:compileVM(uri)
end
self:_compileChain(obj, compiled)
- --self:_compileGlobal(compiled)
+ if self:_hasSetGlobal(uri) then
+ self:_compileGlobal(compiled)
+ end
return obj
end
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index a5c9168d..f78f2690 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -365,6 +365,11 @@ function mt:getName(name, source)
source:bindValue(global, 'get')
source:set('global', true)
source:set('parent', ENVValue)
+ if not global:getLib() then
+ if self.lsp then
+ self.lsp.global:markGet(self:getUri())
+ end
+ end
return global
end
@@ -387,6 +392,9 @@ function mt:setName(name, source, value)
ENVValue:setChild(name, value)
source:set('global', true)
source:set('parentValue', ENVValue)
+ if self.lsp then
+ self.lsp.global:markSet(self:getUri())
+ end
end
function mt:getIndex(source)