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
35
36
37
38
39
40
41
42
43
44
45
46
|
local guide = require 'parser.guide'
local checkSMT = require 'core.setmetatable'
local m = {}
function m:field(source, key, callback)
local used = {}
local found = false
used[source] = true
local node = source.node
used[node] = true
local myKey = guide.getKeyName(source)
if key == myKey then
callback(source.field, 'get')
end
self:eachField(node, 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:eachValue(node, function (src)
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)
end)
checkSMT(self, key, used, found, callback)
end
return m
|