summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/libs/@lua/basic.lni (renamed from server/libs/lua/basic.lni)0
-rw-r--r--server/libs/@lua/bit32.lni (renamed from server/libs/lua/bit32.lni)0
-rw-r--r--server/libs/@lua/coroutine.lni (renamed from server/libs/lua/coroutine.lni)0
-rw-r--r--server/libs/@lua/debug.lni (renamed from server/libs/lua/debug.lni)0
-rw-r--r--server/libs/@lua/file.lni (renamed from server/libs/lua/file.lni)0
-rw-r--r--server/libs/@lua/io.lni (renamed from server/libs/lua/io.lni)0
-rw-r--r--server/libs/@lua/math.lni (renamed from server/libs/lua/math.lni)0
-rw-r--r--server/libs/@lua/os.lni (renamed from server/libs/lua/os.lni)0
-rw-r--r--server/libs/@lua/package.lni (renamed from server/libs/lua/package.lni)0
-rw-r--r--server/libs/@lua/string.lni (renamed from server/libs/lua/string.lni)0
-rw-r--r--server/libs/@lua/table.lni (renamed from server/libs/lua/table.lni)0
-rw-r--r--server/libs/@lua/utf8.lni (renamed from server/libs/lua/utf8.lni)0
-rw-r--r--server/libs/test/basic.lni2
-rw-r--r--server/locale/en-US/libs/@lua/basic.lni (renamed from server/locale/en-US/libs/lua/basic.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/bit32.lni (renamed from server/locale/en-US/libs/lua/bit32.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/coroutine.lni (renamed from server/locale/en-US/libs/lua/coroutine.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/debug.lni (renamed from server/locale/en-US/libs/lua/debug.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/file.lni (renamed from server/locale/en-US/libs/lua/file.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/io.lni (renamed from server/locale/en-US/libs/lua/io.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/math.lni (renamed from server/locale/en-US/libs/lua/math.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/os.lni (renamed from server/locale/en-US/libs/lua/os.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/package.lni (renamed from server/locale/en-US/libs/lua/package.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/string.lni (renamed from server/locale/en-US/libs/lua/string.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/table.lni (renamed from server/locale/en-US/libs/lua/table.lni)0
-rw-r--r--server/locale/en-US/libs/@lua/utf8.lni (renamed from server/locale/en-US/libs/lua/utf8.lni)0
-rw-r--r--server/locale/en-US/script.lni1
-rw-r--r--server/locale/zh-CN/libs/@lua/basic.lni (renamed from server/locale/zh-CN/libs/lua/basic.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/bit32.lni (renamed from server/locale/zh-CN/libs/lua/bit32.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/coroutine.lni (renamed from server/locale/zh-CN/libs/lua/coroutine.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/debug.lni (renamed from server/locale/zh-CN/libs/lua/debug.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/file.lni (renamed from server/locale/zh-CN/libs/lua/file.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/io.lni (renamed from server/locale/zh-CN/libs/lua/io.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/math.lni (renamed from server/locale/zh-CN/libs/lua/math.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/os.lni (renamed from server/locale/zh-CN/libs/lua/os.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/package.lni (renamed from server/locale/zh-CN/libs/lua/package.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/string.lni (renamed from server/locale/zh-CN/libs/lua/string.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/table.lni (renamed from server/locale/zh-CN/libs/lua/table.lni)0
-rw-r--r--server/locale/zh-CN/libs/@lua/utf8.lni (renamed from server/locale/zh-CN/libs/lua/utf8.lni)0
-rw-r--r--server/locale/zh-CN/script.lni1
-rw-r--r--server/src/core/diagnostics.lua4
-rw-r--r--server/src/core/library.lua79
-rw-r--r--server/src/vm/value.lua2
42 files changed, 61 insertions, 28 deletions
diff --git a/server/libs/lua/basic.lni b/server/libs/@lua/basic.lni
index 14c4f669..14c4f669 100644
--- a/server/libs/lua/basic.lni
+++ b/server/libs/@lua/basic.lni
diff --git a/server/libs/lua/bit32.lni b/server/libs/@lua/bit32.lni
index 6920323c..6920323c 100644
--- a/server/libs/lua/bit32.lni
+++ b/server/libs/@lua/bit32.lni
diff --git a/server/libs/lua/coroutine.lni b/server/libs/@lua/coroutine.lni
index be604cb8..be604cb8 100644
--- a/server/libs/lua/coroutine.lni
+++ b/server/libs/@lua/coroutine.lni
diff --git a/server/libs/lua/debug.lni b/server/libs/@lua/debug.lni
index 74d50161..74d50161 100644
--- a/server/libs/lua/debug.lni
+++ b/server/libs/@lua/debug.lni
diff --git a/server/libs/lua/file.lni b/server/libs/@lua/file.lni
index 889cbf2d..889cbf2d 100644
--- a/server/libs/lua/file.lni
+++ b/server/libs/@lua/file.lni
diff --git a/server/libs/lua/io.lni b/server/libs/@lua/io.lni
index bf59969f..bf59969f 100644
--- a/server/libs/lua/io.lni
+++ b/server/libs/@lua/io.lni
diff --git a/server/libs/lua/math.lni b/server/libs/@lua/math.lni
index 20f75315..20f75315 100644
--- a/server/libs/lua/math.lni
+++ b/server/libs/@lua/math.lni
diff --git a/server/libs/lua/os.lni b/server/libs/@lua/os.lni
index 64d5f1c9..64d5f1c9 100644
--- a/server/libs/lua/os.lni
+++ b/server/libs/@lua/os.lni
diff --git a/server/libs/lua/package.lni b/server/libs/@lua/package.lni
index 43ae7344..43ae7344 100644
--- a/server/libs/lua/package.lni
+++ b/server/libs/@lua/package.lni
diff --git a/server/libs/lua/string.lni b/server/libs/@lua/string.lni
index bd454fc0..bd454fc0 100644
--- a/server/libs/lua/string.lni
+++ b/server/libs/@lua/string.lni
diff --git a/server/libs/lua/table.lni b/server/libs/@lua/table.lni
index c48417c3..c48417c3 100644
--- a/server/libs/lua/table.lni
+++ b/server/libs/@lua/table.lni
diff --git a/server/libs/lua/utf8.lni b/server/libs/@lua/utf8.lni
index 876fdd9c..876fdd9c 100644
--- a/server/libs/lua/utf8.lni
+++ b/server/libs/@lua/utf8.lni
diff --git a/server/libs/test/basic.lni b/server/libs/test/basic.lni
new file mode 100644
index 00000000..2b214678
--- /dev/null
+++ b/server/libs/test/basic.lni
@@ -0,0 +1,2 @@
+[ThisIsAVeryVeryLongNameThatNobodyWouldUseItInHisProjectSoICanUseItForTest]
+type = integer
diff --git a/server/locale/en-US/libs/lua/basic.lni b/server/locale/en-US/libs/@lua/basic.lni
index 6a391cac..6a391cac 100644
--- a/server/locale/en-US/libs/lua/basic.lni
+++ b/server/locale/en-US/libs/@lua/basic.lni
diff --git a/server/locale/en-US/libs/lua/bit32.lni b/server/locale/en-US/libs/@lua/bit32.lni
index 13630970..13630970 100644
--- a/server/locale/en-US/libs/lua/bit32.lni
+++ b/server/locale/en-US/libs/@lua/bit32.lni
diff --git a/server/locale/en-US/libs/lua/coroutine.lni b/server/locale/en-US/libs/@lua/coroutine.lni
index 3859ad4e..3859ad4e 100644
--- a/server/locale/en-US/libs/lua/coroutine.lni
+++ b/server/locale/en-US/libs/@lua/coroutine.lni
diff --git a/server/locale/en-US/libs/lua/debug.lni b/server/locale/en-US/libs/@lua/debug.lni
index 42422ae6..42422ae6 100644
--- a/server/locale/en-US/libs/lua/debug.lni
+++ b/server/locale/en-US/libs/@lua/debug.lni
diff --git a/server/locale/en-US/libs/lua/file.lni b/server/locale/en-US/libs/@lua/file.lni
index 4200b65f..4200b65f 100644
--- a/server/locale/en-US/libs/lua/file.lni
+++ b/server/locale/en-US/libs/@lua/file.lni
diff --git a/server/locale/en-US/libs/lua/io.lni b/server/locale/en-US/libs/@lua/io.lni
index 6b25495f..6b25495f 100644
--- a/server/locale/en-US/libs/lua/io.lni
+++ b/server/locale/en-US/libs/@lua/io.lni
diff --git a/server/locale/en-US/libs/lua/math.lni b/server/locale/en-US/libs/@lua/math.lni
index e5bfb122..e5bfb122 100644
--- a/server/locale/en-US/libs/lua/math.lni
+++ b/server/locale/en-US/libs/@lua/math.lni
diff --git a/server/locale/en-US/libs/lua/os.lni b/server/locale/en-US/libs/@lua/os.lni
index 8be67434..8be67434 100644
--- a/server/locale/en-US/libs/lua/os.lni
+++ b/server/locale/en-US/libs/@lua/os.lni
diff --git a/server/locale/en-US/libs/lua/package.lni b/server/locale/en-US/libs/@lua/package.lni
index 3b482ae9..3b482ae9 100644
--- a/server/locale/en-US/libs/lua/package.lni
+++ b/server/locale/en-US/libs/@lua/package.lni
diff --git a/server/locale/en-US/libs/lua/string.lni b/server/locale/en-US/libs/@lua/string.lni
index 3c7b987d..3c7b987d 100644
--- a/server/locale/en-US/libs/lua/string.lni
+++ b/server/locale/en-US/libs/@lua/string.lni
diff --git a/server/locale/en-US/libs/lua/table.lni b/server/locale/en-US/libs/@lua/table.lni
index d32ea4ae..d32ea4ae 100644
--- a/server/locale/en-US/libs/lua/table.lni
+++ b/server/locale/en-US/libs/@lua/table.lni
diff --git a/server/locale/en-US/libs/lua/utf8.lni b/server/locale/en-US/libs/@lua/utf8.lni
index c7ab9bf3..c7ab9bf3 100644
--- a/server/locale/en-US/libs/lua/utf8.lni
+++ b/server/locale/en-US/libs/@lua/utf8.lni
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni
index 354d981d..38f571c3 100644
--- a/server/locale/en-US/script.lni
+++ b/server/locale/en-US/script.lni
@@ -14,6 +14,7 @@ DIAG_DIAGNOSTICS = 'Diagnostics'
DIAG_SYNTAX_CHECK = 'Syntax Check'
DIAG_NEED_VERSION = 'Supported in {}'
DIAG_DEFINED_VERSION = 'Defined in {}, current is {}'
+DIAG_DEFINED_CUSTOM = 'Defined in {}'
MWS_NOT_SUPPORT = '{} dose not support multi workspace for now, I may need to restart to support the new workspace ...'
MWS_RESTART = 'Restart'
diff --git a/server/locale/zh-CN/libs/lua/basic.lni b/server/locale/zh-CN/libs/@lua/basic.lni
index 50124adf..50124adf 100644
--- a/server/locale/zh-CN/libs/lua/basic.lni
+++ b/server/locale/zh-CN/libs/@lua/basic.lni
diff --git a/server/locale/zh-CN/libs/lua/bit32.lni b/server/locale/zh-CN/libs/@lua/bit32.lni
index 35aa22cc..35aa22cc 100644
--- a/server/locale/zh-CN/libs/lua/bit32.lni
+++ b/server/locale/zh-CN/libs/@lua/bit32.lni
diff --git a/server/locale/zh-CN/libs/lua/coroutine.lni b/server/locale/zh-CN/libs/@lua/coroutine.lni
index f2912c70..f2912c70 100644
--- a/server/locale/zh-CN/libs/lua/coroutine.lni
+++ b/server/locale/zh-CN/libs/@lua/coroutine.lni
diff --git a/server/locale/zh-CN/libs/lua/debug.lni b/server/locale/zh-CN/libs/@lua/debug.lni
index 22e6d3b3..22e6d3b3 100644
--- a/server/locale/zh-CN/libs/lua/debug.lni
+++ b/server/locale/zh-CN/libs/@lua/debug.lni
diff --git a/server/locale/zh-CN/libs/lua/file.lni b/server/locale/zh-CN/libs/@lua/file.lni
index 73dfd67d..73dfd67d 100644
--- a/server/locale/zh-CN/libs/lua/file.lni
+++ b/server/locale/zh-CN/libs/@lua/file.lni
diff --git a/server/locale/zh-CN/libs/lua/io.lni b/server/locale/zh-CN/libs/@lua/io.lni
index 4a8a72a0..4a8a72a0 100644
--- a/server/locale/zh-CN/libs/lua/io.lni
+++ b/server/locale/zh-CN/libs/@lua/io.lni
diff --git a/server/locale/zh-CN/libs/lua/math.lni b/server/locale/zh-CN/libs/@lua/math.lni
index f1a6768a..f1a6768a 100644
--- a/server/locale/zh-CN/libs/lua/math.lni
+++ b/server/locale/zh-CN/libs/@lua/math.lni
diff --git a/server/locale/zh-CN/libs/lua/os.lni b/server/locale/zh-CN/libs/@lua/os.lni
index 6a4bcf0f..6a4bcf0f 100644
--- a/server/locale/zh-CN/libs/lua/os.lni
+++ b/server/locale/zh-CN/libs/@lua/os.lni
diff --git a/server/locale/zh-CN/libs/lua/package.lni b/server/locale/zh-CN/libs/@lua/package.lni
index 209a9dc1..209a9dc1 100644
--- a/server/locale/zh-CN/libs/lua/package.lni
+++ b/server/locale/zh-CN/libs/@lua/package.lni
diff --git a/server/locale/zh-CN/libs/lua/string.lni b/server/locale/zh-CN/libs/@lua/string.lni
index cc582783..cc582783 100644
--- a/server/locale/zh-CN/libs/lua/string.lni
+++ b/server/locale/zh-CN/libs/@lua/string.lni
diff --git a/server/locale/zh-CN/libs/lua/table.lni b/server/locale/zh-CN/libs/@lua/table.lni
index 9163d8e5..9163d8e5 100644
--- a/server/locale/zh-CN/libs/lua/table.lni
+++ b/server/locale/zh-CN/libs/@lua/table.lni
diff --git a/server/locale/zh-CN/libs/lua/utf8.lni b/server/locale/zh-CN/libs/@lua/utf8.lni
index 0af45153..0af45153 100644
--- a/server/locale/zh-CN/libs/lua/utf8.lni
+++ b/server/locale/zh-CN/libs/@lua/utf8.lni
diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni
index 72db5495..a5b61475 100644
--- a/server/locale/zh-CN/script.lni
+++ b/server/locale/zh-CN/script.lni
@@ -14,6 +14,7 @@ DIAG_DIAGNOSTICS = '诊断'
DIAG_SYNTAX_CHECK = '语法检查'
DIAG_NEED_VERSION = '在 {} 中是合法的'
DIAG_DEFINED_VERSION = '在 {} 中有定义,当前为 {}'
+DIAG_DEFINED_CUSTOM = '在 {} 中有定义'
MWS_NOT_SUPPORT = '{} 目前还不支持多工作目录,我可能需要重启才能支持新的工作目录...'
MWS_RESTART = '重启'
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index 3e790fa3..7bf43675 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -338,9 +338,13 @@ return function (vm, lines, uri)
session:doDiagnostics(session.searchUndefinedGlobal, 'undefined-global', function (key)
local message = lang.script('DIAG_UNDEF_GLOBAL', key)
local otherVersion = library.other[key]
+ local customLib = library.custom[key]
if otherVersion then
message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(otherVersion, '/'), config.config.runtime.version))
end
+ if customLib then
+ message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_CUSTOM', table.concat(customLib, '/')))
+ end
return {
level = DiagnosticSeverity.Warning,
message = message,
diff --git a/server/src/core/library.lua b/server/src/core/library.lua
index f943bf8a..d9ac969a 100644
--- a/server/src/core/library.lua
+++ b/server/src/core/library.lua
@@ -108,20 +108,40 @@ local function insertOther(tbl, key, value)
table.sort(tbl[key])
end
-local function mergeSource(alllibs, name, lib)
+local function insertCustom(tbl, key, value, libName)
+ if not tbl[key] then
+ tbl[key] = {}
+ end
+ tbl[key][#tbl[key]+1] = libName
+ table.sort(tbl[key])
+end
+
+local function isEnableGlobal(libName)
+ return libName:sub(1, 1) == '@'
+end
+
+local function mergeSource(alllibs, name, lib, libName)
if not lib.source then
- local suc = insertGlobal(alllibs.global, name, lib)
- if not suc then
- insertOther(alllibs.other, name, lib)
+ if isEnableGlobal(libName) then
+ local suc = insertGlobal(alllibs.global, name, lib)
+ if not suc then
+ insertOther(alllibs.other, name, lib)
+ end
+ else
+ insertCustom(alllibs.custom, name, lib, libName)
end
return
end
for _, source in ipairs(lib.source) do
local sourceName = source.name or name
if source.type == 'global' then
- local suc = insertGlobal(alllibs.global, sourceName, lib)
- if not suc then
- insertOther(alllibs.other, sourceName, lib)
+ if isEnableGlobal(libName) then
+ local suc = insertGlobal(alllibs.global, sourceName, lib)
+ if not suc then
+ insertOther(alllibs.other, sourceName, lib)
+ end
+ else
+ insertCustom(alllibs.custom, sourceName, lib, libName)
end
elseif source.type == 'library' then
insertGlobal(alllibs.library, sourceName, lib)
@@ -172,10 +192,12 @@ local function insertChild(tbl, name, key, value)
tbl[name].child[key] = copy(value)
end
-local function mergeParent(alllibs, name, lib)
+local function mergeParent(alllibs, name, lib, libName)
for _, parent in ipairs(lib.parent) do
if parent.type == 'global' then
- insertChild(alllibs.global, parent.name, name, lib)
+ if isEnableGlobal(libName) then
+ insertChild(alllibs.global, parent.name, name, lib)
+ end
elseif parent.type == 'library' then
insertChild(alllibs.library, parent.name, name, lib)
elseif parent.type == 'object' then
@@ -184,15 +206,15 @@ local function mergeParent(alllibs, name, lib)
end
end
-local function mergeLibs(alllibs, libs)
+local function mergeLibs(alllibs, libs, libName)
if not libs then
return
end
for _, lib in pairs(libs) do
if lib.parent then
- mergeParent(alllibs, lib.name, lib)
+ mergeParent(alllibs, lib.name, lib, libName)
else
- mergeSource(alllibs, lib.name, lib)
+ mergeSource(alllibs, lib.name, lib, libName)
end
end
end
@@ -240,24 +262,29 @@ local function init()
Library.library = table.container()
Library.object = table.container()
Library.other = table.container()
+ Library.custom = table.container()
- for path in scan(ROOT / 'libs') do
- local libs
- local buf = io.load(path)
- if buf then
- libs = table.container()
- xpcall(lni, log.error, buf, path:string(), {libs})
- fix(libs)
- end
- local relative = fs.relative(path, ROOT)
+ for libPath in (ROOT / 'libs'):list_directory() do
+ local enableGlobal
+ local libName = libPath:filename():string()
+ for path in scan(libPath) do
+ local libs
+ local buf = io.load(path)
+ if buf then
+ libs = table.container()
+ xpcall(lni, log.error, buf, path:string(), {libs})
+ fix(libs)
+ end
+ local relative = fs.relative(path, ROOT)
- local locale = loadLocale('en-US', relative)
- mergeLocale(libs, locale)
- if id ~= 'en-US' then
- locale = loadLocale(id, relative)
+ local locale = loadLocale('en-US', relative)
mergeLocale(libs, locale)
+ if id ~= 'en-US' then
+ locale = loadLocale(id, relative)
+ mergeLocale(libs, locale)
+ end
+ mergeLibs(Library, libs, libName)
end
- mergeLibs(Library, libs)
end
end
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 7e2c3663..625066b1 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -232,9 +232,7 @@ function mt:flushChild(child)
for index in pairs(self._child) do
if not alived[index] then
self._child[index] = nil
- goto CONTINUE
end
- ::CONTINUE::
end
end