From 28c04562c5d3869eb47d1190349d4c68655aefe8 Mon Sep 17 00:00:00 2001 From: sumneko Date: Fri, 24 May 2019 11:29:15 +0800 Subject: =?UTF-8?q?fixed=20#38=20=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86=20pa?= =?UTF-8?q?irs=20=E4=B8=8E=20ipairs=20=E7=9A=84=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/vm/function.lua | 4 ++-- server/src/vm/ipairs.lua | 3 +++ server/src/vm/library.lua | 1 + server/src/vm/multi.lua | 3 +++ 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 -- cgit v1.2.3