summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-05-24 11:29:15 +0800
committersumneko <sumneko@hotmail.com>2019-05-24 11:29:15 +0800
commit28c04562c5d3869eb47d1190349d4c68655aefe8 (patch)
tree09cb8a5789f9a11614a828b92a2605b92f932851 /server
parent72a491c98f68a8483183b0d800309a6f99e43e3b (diff)
downloadlua-language-server-28c04562c5d3869eb47d1190349d4c68655aefe8.zip
fixed #38 特殊处理 pairs 与 ipairs 的返回值
Diffstat (limited to 'server')
-rw-r--r--server/src/vm/function.lua4
-rw-r--r--server/src/vm/ipairs.lua3
-rw-r--r--server/src/vm/library.lua1
-rw-r--r--server/src/vm/multi.lua3
4 files changed, 9 insertions, 2 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua
index 723c5ff0..1106a0c9 100644
--- a/server/src/vm/function.lua
+++ b/server/src/vm/function.lua
@@ -154,7 +154,7 @@ function mt:setReturn(index, value)
self.returns = createMulti()
end
if value then
- self.returns[index] = value
+ self.returns:set(index, value)
if self._global then
value:markGlobal()
end
@@ -174,7 +174,7 @@ function mt:mergeReturn(index, value)
self.returns[index]:mergeValue(value)
self.returns[index] = value
else
- self.returns[index] = value
+ self.returns:set(index, value)
end
end
if self._global then
diff --git a/server/src/vm/ipairs.lua b/server/src/vm/ipairs.lua
index 58c7d827..cb8356da 100644
--- a/server/src/vm/ipairs.lua
+++ b/server/src/vm/ipairs.lua
@@ -1,8 +1,10 @@
local mt = require 'vm.manager'
+local library = require 'vm.library'
---@param func emmyFunction
function mt:callIpairs(func, values, source)
local tbl = values[1]
+ func:setReturn(1, library.special['@ipairs'])
func:setReturn(2, tbl)
end
@@ -23,6 +25,7 @@ end
---@param func emmyFunction
function mt:callPairs(func, values, source)
local tbl = values[1]
+ func:setReturn(1, library.special['next'])
func:setReturn(2, tbl)
end
diff --git a/server/src/vm/library.lua b/server/src/vm/library.lua
index 258118a7..018d69f3 100644
--- a/server/src/vm/library.lua
+++ b/server/src/vm/library.lua
@@ -108,4 +108,5 @@ return {
value = buildLibValue,
child = buildLibChild,
clear = clearCache,
+ special = Special,
}
diff --git a/server/src/vm/multi.lua b/server/src/vm/multi.lua
index c2748a26..4b27b8cf 100644
--- a/server/src/vm/multi.lua
+++ b/server/src/vm/multi.lua
@@ -25,6 +25,9 @@ function mt:get(index)
end
function mt:set(index, value)
+ if index > self.len then
+ self.len = index
+ end
self[index] = value
end