summaryrefslogtreecommitdiff
path: root/server-beta/src/core/getfield.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/core/getfield.lua')
-rw-r--r--server-beta/src/core/getfield.lua41
1 files changed, 23 insertions, 18 deletions
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua
index 03aa7854..60d3d8d4 100644
--- a/server-beta/src/core/getfield.lua
+++ b/server-beta/src/core/getfield.lua
@@ -9,28 +9,27 @@ function m:field(source, key, callback)
used[source] = true
local node = source.node
- self:eachDef(node, function (src)
- used[src] = true
- end)
+ local myKey = guide.getKeyName(node)
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'get')
+ if myKey == key then
+ callback(source)
end
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
+ self:eachDef(node, function (src)
+ if myKey ~= key then
+ return
+ end
+ 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
@@ -47,4 +46,10 @@ function m:field(source, key, callback)
checkSMT(self, key, used, found, callback)
end
+function m:value(source, callback)
+ if source.value then
+ self:eachValue(source.value, callback)
+ end
+end
+
return m