1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
local mt = require 'vm.manager'
local multi = require 'vm.multi'
function mt:callPcall(func, values, source)
local funcValue = values:first()
if not funcValue then
return
end
local realFunc = funcValue:getFunction()
if not realFunc then
return
end
local argList = multi()
values:eachValue(function (i, v)
if i >= 2 then
argList:push(v)
end
end)
self:call(funcValue, argList, source)
if realFunc ~= func then
func:setReturn(1, self:createValue('boolean', source))
realFunc:getReturn():eachValue(function (i, v)
func:setReturn(i + 1, v)
end)
end
end
function mt:callXpcall(func, values, source)
local funcValue = values:first()
if not funcValue then
return
end
local realFunc = funcValue:getFunction()
if not realFunc then
return
end
local argList = multi()
values:eachValue(function (i, v)
if i >= 3 then
argList:push(v)
end
end)
self:call(funcValue, argList, source)
if realFunc ~= func then
func:setReturn(1, self:createValue('boolean', source))
realFunc:getReturn():eachValue(function (i, v)
func:setReturn(i + 1, v)
end)
end
end
|