summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/core/engineer.lua2
-rw-r--r--server-beta/src/parser/guide.lua27
2 files changed, 26 insertions, 3 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua
index dc3fd721..a9251996 100644
--- a/server-beta/src/core/engineer.lua
+++ b/server-beta/src/core/engineer.lua
@@ -29,7 +29,7 @@ end
--- 查找所有域的引用
function mt:eachRefAsField(obj, callback)
local node = obj.node
- guide.eachRef(node, function (ref)
+ guide.eachChildRef(node, function (ref)
if ref.type == 'setglobal' or ref.type == 'setfield' then
callback(ref, 'set')
elseif ref.type == 'getglobal' or ref.type == 'getfield' then
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index 37dd8061..f89b1f5f 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -359,7 +359,7 @@ function m.getKeyName(obj)
end
--- 获取对象所有field的key与valueObj
-function m.eachField(obj, callback)
+function m.eachChildValue(obj, callback)
local vref = obj.vref
if not vref then
return
@@ -378,7 +378,7 @@ function m.eachField(obj, callback)
end
--- 获取对象所有指定field的key与valueObj
-function m.eachFieldOf(obj, field, callback)
+function m.eachChildValueOf(obj, field, callback)
local vref = obj.vref
if not vref then
return
@@ -397,6 +397,29 @@ function m.eachFieldOf(obj, field, callback)
end
end
+--- 获取对象所有field的引用
+function m.eachChildRef(obj, callback)
+ local vref = obj.vref
+ if not vref then
+ return
+ end
+ for x = 1, #vref do
+ local v = vref[x]
+ local cref = v.ref
+ if cref then
+ for y = 1, #cref do
+ local co = cref[y]
+ local ref = co.ref
+ if ref then
+ for i = 1, #ref do
+ callback(ref[i])
+ end
+ end
+ end
+ end
+ end
+end
+
--- 获取对象的所有引用
function m.eachRef(obj, callback)
local ref = obj.ref