summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/matcher/find_lib.lua14
-rw-r--r--server/src/matcher/vm.lua34
2 files changed, 40 insertions, 8 deletions
diff --git a/server/src/matcher/find_lib.lua b/server/src/matcher/find_lib.lua
index d2b5d6a8..e4ea6e02 100644
--- a/server/src/matcher/find_lib.lua
+++ b/server/src/matcher/find_lib.lua
@@ -22,7 +22,19 @@ local function findLib(var)
return lib, fullKey, false
end
else
- return lib, lib.name, false
+ local res
+ if not lib.source then
+ return lib, lib.nick or lib.name, false
+ end
+ for _, source in ipairs(lib.source) do
+ if source.type == value.parentType then
+ res = source
+ end
+ end
+ if not res then
+ return lib, lib.nick or lib.name, false
+ end
+ return lib, res.nick or res.name or lib.nick or lib.name, false
end
end
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 16d5fe20..928a954f 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -386,9 +386,34 @@ function mt:createValue(type, source, v)
source = source or DefaultSource,
value = v,
}
+ local lib = library.object[type]
+ if lib then
+ self:getLibChild(value, lib, 'object')
+ end
return value
end
+function mt:getLibChild(value, lib, parentType)
+ if lib.child then
+ if self.libraryChild[lib] then
+ value.child = self.libraryChild[lib]
+ return
+ end
+ self.libraryChild[lib] = {}
+ for fName, fLib in pairs(lib.child) do
+ local fField = self:createField(value, fName)
+ local fValue = self:getLibValue(fLib, parentType)
+ self:setValue(fField, fValue)
+ end
+ if value.child then
+ for k, v in pairs(value.child) do
+ self.libraryChild[lib][k] = v
+ end
+ end
+ value.child = self.libraryChild[lib]
+ end
+end
+
function mt:getLibValue(lib, parentType, v)
if self.libraryValue[lib] then
return self.libraryValue[lib]
@@ -433,13 +458,7 @@ function mt:getLibValue(lib, parentType, v)
value.lib = lib
value.parentType = parentType
- if lib.child then
- for fName, fLib in pairs(lib.child) do
- local fField = self:createField(value, fName)
- local fValue = self:getLibValue(fLib, parentType)
- self:setValue(fField, fValue)
- end
- end
+ self:getLibChild(value, lib, parentType)
return value
end
@@ -875,6 +894,7 @@ local function compile(ast)
calls = {},
},
libraryValue = {},
+ libraryChild = {},
}, mt)
-- 创建初始环境