diff options
Diffstat (limited to 'server-beta/src/core/_G.lua')
-rw-r--r-- | server-beta/src/core/_G.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server-beta/src/core/_G.lua b/server-beta/src/core/_G.lua new file mode 100644 index 00000000..3a28c7ac --- /dev/null +++ b/server-beta/src/core/_G.lua @@ -0,0 +1,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 |