blob: 5bb341b2d17b1399e36fbe362df901d154d9e46a (
plain)
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
51
|
local vm = require 'vm.vm'
local function checkMetaArg1(source, callback)
local node, index = vm.getArgInfo(source)
local special = vm.getSpecial(node)
if special == 'setmetatable' and index == 1 then
local mt = node.next.args[2]
if mt then
vm.eachField(mt, function (src)
if vm.getKeyName(src) == 's|__index' then
if src.value then
vm.eachField(src.value, callback)
end
end
end)
end
end
end
local function checkMetaRecv(source, callback)
if not source or source.type ~= 'select' then
return
end
if source.index ~= 1 then
return
end
local call = source.vararg
if not call or call.type ~= 'call' then
return
end
local special = vm.getSpecial(call.node)
if special ~= 'setmetatable' then
return
end
vm.eachFieldInTable(call.args[1])
local mt = call.args[2]
if mt then
vm.eachField(mt, function (src)
if vm.getKeyName(src) == 's|__index' then
if src.value then
vm.eachField(src.value, callback)
end
end
end)
end
end
function vm.checkMetaValue(source, callback)
checkMetaArg1(source, callback)
checkMetaRecv(source.value, callback)
end
|