summaryrefslogtreecommitdiff
path: root/server-beta/src/core/_G.lua
blob: 3a28c7ac87bce4109e6a2ed7d1e03543368a37bc (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
local m = {}

function m:def(source, callback)
    local parent = source.parent
    if parent.type == 'setfield'
    or parent.type == 'setindex'
    or parent.type == 'setmethod' then
        callback(parent, 'set')
    elseif parent.type == 'getfield'
    or     parent.type == 'getindex' then
        self:search(parent, 'special', 'def', callback)
    elseif parent.type == 'callargs' then
        self:search(parent.parent, 'special', 'def', callback)
    end
end

function m:ref(source, callback)
    local parent = source.parent
    if parent.type == 'setfield'
    or parent.type == 'setindex'
    or parent.type == 'setmethod' then
        callback(parent, 'set')
    elseif parent.type == 'getfield'
    or     parent.type == 'getindex'
    or     parent.type == 'getmethod' then
        callback(parent, 'get')
    elseif parent.type == 'getfield' then
        self:search(parent, 'special', 'ref', callback)
    elseif parent.type == 'callargs' then
        self:search(parent.parent, 'special', 'ref', callback)
    end
end

return m