summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-11 11:35:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-11 11:35:03 +0800
commit9856a4045b270b189e5586b8b0d6e6fc8139c964 (patch)
treefad012bf9584c2b4f90f7b873d1bafc1480ff645
parentcd53ef59e59e71ec2ad9205c59f61c8d3565a4cd (diff)
downloadlua-language-server-9856a4045b270b189e5586b8b0d6e6fc8139c964.zip
更新vm
-rw-r--r--server/libs/lua53/basic.lni20
-rw-r--r--server/src/matcher/vm.lua17
2 files changed, 36 insertions, 1 deletions
diff --git a/server/libs/lua53/basic.lni b/server/libs/lua53/basic.lni
index ae25c68d..bbd6139e 100644
--- a/server/libs/lua53/basic.lni
+++ b/server/libs/lua53/basic.lni
@@ -203,6 +203,26 @@ default = 0
[next]
[pairs]
+[[.args]]
+name = 't'
+type = 'table'
+[[.returns]]
+name = 'next'
+type = 'function'
+returns = {
+ 1 = {
+ name = 'key',
+ },
+ 2 = {
+ name = 'object',
+ },
+}
+[[.returns]]
+name = 't'
+type = 'table'
+[[.returns]]
+name = 'nil'
+type = 'nil'
[pcall]
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 18e1ddd3..e5230015 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -316,6 +316,8 @@ function mt:getLibValue(lib)
value = self:createNumber(lib.value)
elseif tp == 'integer' then
value = self:createInteger(lib.value)
+ elseif tp == 'nil' then
+ value = self:createNil()
else
value = self:createCustom(tp)
end
@@ -600,7 +602,20 @@ end
function mt:doIn(action)
self.scope:push()
- local values = self:unpackList(action.exp)
+ local func
+ local list = {
+ type = 'list'
+ }
+ if action.exp.type == 'list' then
+ func = self:getExp(action.exp[1])
+ for i = 2, #action.exp do
+ list[i-1] = action.exp[i]
+ end
+ else
+ func = self:getExp(action.exp)
+ end
+ local args = self:unpackList(list)
+ local values = self:call(func, args)
self:forList(action.arg, function (arg)
local var = self:createLocal(arg[1], arg)
self:setValue(var, table.remove(values, 1))