summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/getfield.lua73
-rw-r--r--server-beta/src/core/getglobal.lua65
2 files changed, 78 insertions, 60 deletions
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua
index 60d3d8d4..4cc5d3f8 100644
--- a/server-beta/src/core/getfield.lua
+++ b/server-beta/src/core/getfield.lua
@@ -3,44 +3,57 @@ local checkSMT = require 'core.setmetatable'
local m = {}
+function m:ref(source, callback)
+ local key = guide.getKeyName(source)
+ self:eachField(source.node, key, function (src, mode)
+ if mode == 'set' or mode == 'get' then
+ callback(src, mode)
+ end
+ end)
+end
+
function m:field(source, key, callback)
local used = {}
local found = false
used[source] = true
- local node = source.node
- local myKey = guide.getKeyName(node)
-
- if myKey == key then
- callback(source)
- end
-
- self:eachDef(node, function (src)
- if myKey ~= key then
- return
- end
+ self:eachRef(source, function (src)
used[src] = true
- if node.type == 'setfield'
- or node.type == 'setindex'
- or node.type == 'setmethod' then
- callback(src, 'set')
- elseif node.type == 'getfield'
- or node.type == 'getindex'
- or node.type == 'getmethod' then
- callback(src, 'get')
- end
- end)
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
+ if src.type == 'getfield' then
+ if guide.getKeyName(src.field) == key then
+ callback(src.field, 'get')
+ end
+ elseif src.type == 'setfield' then
+ if guide.getKeyName(src.field) == key then
+ callback(src.field, 'set')
+ end
+ elseif src.type == 'getmethod' then
+ if guide.getKeyName(src.method) == key then
+ callback(src.method, 'get')
end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
+ elseif src.type == 'setmethod' then
+ if guide.getKeyName(src.method) == key then
+ callback(src.method, 'set')
end
- end)
+ elseif src.type == 'getindex' then
+ if guide.getKeyName(src.index) == key then
+ callback(src.index, 'get')
+ end
+ elseif src.type == 'setindex' then
+ if guide.getKeyName(src.index) == key then
+ callback(src.index, 'set')
+ end
+ elseif src.type == 'getglobal' then
+ if guide.getKeyName(src.parent) == key then
+ callback(src.parent, 'get')
+ end
+ elseif src.type == 'setglobal' then
+ --if guide.getKeyName(src.parent) == key then
+ -- callback(src.parent, 'set')
+ --end
+ else
+ self:eachField(src, key, callback)
+ end
end)
checkSMT(self, key, used, found, callback)
diff --git a/server-beta/src/core/getglobal.lua b/server-beta/src/core/getglobal.lua
index 4b4f4a10..a8bcb04c 100644
--- a/server-beta/src/core/getglobal.lua
+++ b/server-beta/src/core/getglobal.lua
@@ -66,45 +66,50 @@ function m:field(source, key, callback)
local found = false
used[source] = true
- local node = source.node
- local myKey = guide.getKeyName(node)
-
- if myKey == key then
- callback(source)
- end
-
- self:eachDef(node, function (src)
- if myKey ~= key then
- return
- end
+ self:eachRef(source, function (src)
used[src] = true
- if node.type == 'setfield'
- or node.type == 'setindex'
- or node.type == 'setmethod' then
- callback(src, 'set')
- elseif node.type == 'getfield'
- or node.type == 'getindex'
- or node.type == 'getmethod' then
- callback(src, 'get')
- end
- end)
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
+ if src.type == 'getfield' then
+ if guide.getKeyName(src.field) == key then
+ callback(src.field, 'get')
+ end
+ elseif src.type == 'setfield' then
+ if guide.getKeyName(src.field) == key then
+ callback(src.field, 'set')
end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
+ elseif src.type == 'getmethod' then
+ if guide.getKeyName(src.method) == key then
+ callback(src.method, 'get')
end
- end)
+ elseif src.type == 'setmethod' then
+ if guide.getKeyName(src.method) == key then
+ callback(src.method, 'set')
+ end
+ elseif src.type == 'getindex' then
+ if guide.getKeyName(src.index) == key then
+ callback(src.index, 'get')
+ end
+ elseif src.type == 'setindex' then
+ if guide.getKeyName(src.index) == key then
+ callback(src.index, 'set')
+ end
+ elseif src.type == 'getglobal' then
+ if guide.getKeyName(src.parent) == key then
+ callback(src.parent, 'get')
+ end
+ elseif src.type == 'setglobal' then
+ --if guide.getKeyName(src.parent) == key then
+ -- callback(src.parent, 'set')
+ --end
+ else
+ self:eachField(src, key, callback)
+ end
end)
checkSMT(self, key, used, found, callback)
end
function m:value(source, callback)
+ callback(source)
if source.value then
self:eachValue(source.value, callback)
end