summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/engineer.lua11
-rw-r--r--server-beta/src/parser/guide.lua15
2 files changed, 18 insertions, 8 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua
index 0def3ff1..dc3fd721 100644
--- a/server-beta/src/core/engineer.lua
+++ b/server-beta/src/core/engineer.lua
@@ -29,12 +29,11 @@ end
--- 查找所有域的引用
function mt:eachRefAsField(obj, callback)
local node = obj.node
- guide.eachFieldOf(node, guide.getKeyName(obj), function (value)
- local tp = value.type
- if tp == 'setglobal' or tp == 'setfield' then
- callback(value, 'set')
- elseif tp == 'getglobal' or tp == 'getfield' then
- callback(value, 'get')
+ guide.eachRef(node, function (ref)
+ if ref.type == 'setglobal' or ref.type == 'setfield' then
+ callback(ref, 'set')
+ elseif ref.type == 'getglobal' or ref.type == 'getfield' then
+ callback(ref, 'get')
end
end)
end
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index fdd29be7..37dd8061 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -352,9 +352,9 @@ end
--- 获取对象作为key时的名字
function m.getKeyName(obj)
if obj.type == 'getglobal' or obj.type == 'setglobal' then
- return 'string|' .. obj[1]
+ return 's|' .. obj[1]
elseif obj.type == 'getfield' or obj.type == 'getglobal' then
- return 'string|' .. obj[1]
+ return 's|' .. obj[1]
end
end
@@ -397,4 +397,15 @@ function m.eachFieldOf(obj, field, callback)
end
end
+--- 获取对象的所有引用
+function m.eachRef(obj, callback)
+ local ref = obj.ref
+ if not ref then
+ return
+ end
+ for i = 1, #ref do
+ callback(ref[i])
+ end
+end
+
return m