diff options
Diffstat (limited to 'server-beta/src/core/field.lua')
-rw-r--r-- | server-beta/src/core/field.lua | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/server-beta/src/core/field.lua b/server-beta/src/core/field.lua index 95c9954f..997b38e3 100644 --- a/server-beta/src/core/field.lua +++ b/server-beta/src/core/field.lua @@ -3,23 +3,33 @@ local guide = require 'parser.guide' local m = {} function m:def(source, callback) - local node = source.parent.node - local key = guide.getKeyName(source) - self:eachField(node, key, function (src, mode) - if mode == 'set' then - callback(src, mode) - end - end) + local parent = source.parent + if parent.type == 'setfield' or parent.type == 'getfield' then + local node = parent.node + local key = guide.getKeyName(source) + self:eachField(node, key, function (src, mode) + if mode == 'set' then + callback(src, mode) + end + end) + elseif parent.type == 'tablefield' then + self:eachDef(parent.value, callback) + end end function m:ref(source, callback) - local node = source.parent.node - local key = guide.getKeyName(source) - self:eachField(node, key, function (src, mode) - if mode == 'set' or mode == 'get' then - callback(src, mode) - end - end) + local parent = source.parent + if parent.type == 'setfield' or parent.type == 'getfield' then + local node = parent.node + local key = guide.getKeyName(source) + self:eachField(node, key, function (src, mode) + if mode == 'set' or mode == 'get' then + callback(src, mode) + end + end) + elseif parent.type == 'tablefield' then + self:eachDef(parent.value, callback) + end end function m:value(source, callback) |