summaryrefslogtreecommitdiff
path: root/server/src/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-29 13:46:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-29 13:46:28 +0800
commitcc33507654fa35640118b13bdd3f19696631980a (patch)
tree636cad7ea765a4439d9655dcf9cba39f3f68e17c /server/src/vm
parent9c2843279fb04b75169057c3d81a93ce87ebcf34 (diff)
downloadlua-language-server-cc33507654fa35640118b13bdd3f19696631980a.zip
尽量不合并value
Diffstat (limited to 'server/src/vm')
-rw-r--r--server/src/vm/local.lua8
-rw-r--r--server/src/vm/value.lua20
-rw-r--r--server/src/vm/vm.lua5
3 files changed, 28 insertions, 5 deletions
diff --git a/server/src/vm/local.lua b/server/src/vm/local.lua
index b8a387fe..0da5112f 100644
--- a/server/src/vm/local.lua
+++ b/server/src/vm/local.lua
@@ -9,11 +9,17 @@ mt.type = 'local'
mt._close = math.maxinteger
function mt:setValue(value)
+ if not value then
+ return
+ end
if self.value then
- self.value:mergeValue(value)
+ --self.value:mergeValue(value)
+ self.value:mergeType(value)
+ self.value = value
else
self.value = value
end
+ return value
end
function mt:getValue()
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 35f92b5d..872e96b6 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -96,8 +96,9 @@ function mt:rawSet(index, value, source)
self._child = {}
end
if self._child[index] then
- self._child[index]:mergeValue(value)
- --self._child[index] = value
+ --self._child[index]:mergeValue(value)
+ self._child[index]:mergeType(value)
+ self._child[index] = value
else
self._child[index] = value
end
@@ -262,6 +263,21 @@ function mt:eachChild(callback, mark, foundIndex)
return method:eachChild(callback, mark, foundIndex)
end
+function mt:mergeType(value)
+ if self == value then
+ return
+ end
+ if not value then
+ return
+ end
+ if value._type then
+ for tp, rate in pairs(value._type) do
+ self:setType(tp, rate)
+ end
+ end
+ value._type = self._type
+end
+
function mt:mergeValue(value)
if self == value then
return
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 3b52e1f0..5d6b024f 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -941,6 +941,7 @@ function mt:doLocalFunction(action)
local func = self:buildFunction(action)
func:addInfo('local', name)
loc:setValue(func)
+ name:bindValue(func, 'local')
end
end
end
@@ -1098,13 +1099,13 @@ function mt:createLocal(key, source, value)
end
if not value then
- value = valueMgr.create('nil', self:getDefaultSource())
+ value = self:createValue('nil', source)
end
loc = localMgr.create(key, source, value)
self:saveLocal(key, loc)
self:bindLocal(source, loc, 'local')
- value:addInfo('local', source or self:getDefaultSource())
+ value:addInfo('local', source)
return loc
end