diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-09 15:56:36 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-09 15:56:36 +0800 |
commit | d29789157f0988dd0f189c35ed581cb3cfdeb5c8 (patch) | |
tree | fa073a6cfc5dc32a8e6f691064a61d3978fb9eaf | |
parent | 79961aa0bd5ea6d297683e976165ea70866c12d3 (diff) | |
download | lua-language-server-d29789157f0988dd0f189c35ed581cb3cfdeb5c8.zip |
LuaJIT的API
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | server/libs/@lua/basic.lni | 14 | ||||
-rw-r--r-- | server/libs/@lua/debug.lni | 21 | ||||
-rw-r--r-- | server/libs/@lua/io.lni | 70 | ||||
-rw-r--r-- | server/libs/@lua/math.lni | 18 | ||||
-rw-r--r-- | server/libs/@lua/os.lni | 11 | ||||
-rw-r--r-- | server/libs/@lua/package.lni | 5 | ||||
-rw-r--r-- | server/libs/@lua/string.lni | 11 | ||||
-rw-r--r-- | server/libs/@lua/table.lni | 2 | ||||
-rw-r--r-- | server/locale/en-US/libs/@lua/debug.lni | 34 | ||||
-rw-r--r-- | server/locale/en-US/libs/@lua/io.lni | 61 | ||||
-rw-r--r-- | server/locale/en-US/libs/@lua/os.lni | 3 | ||||
-rw-r--r-- | server/locale/en-US/libs/@lua/string.lni | 3 | ||||
-rw-r--r-- | server/locale/zh-CN/libs/@lua/debug.lni | 36 | ||||
-rw-r--r-- | server/locale/zh-CN/libs/@lua/io.lni | 61 | ||||
-rw-r--r-- | server/locale/zh-CN/libs/@lua/os.lni | 3 | ||||
-rw-r--r-- | server/locale/zh-CN/libs/@lua/string.lni | 3 | ||||
-rw-r--r-- | server/main.lua | 2 |
18 files changed, 313 insertions, 48 deletions
diff --git a/package.json b/package.json index bce22f63..940594c2 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "Lua 5.1", "Lua 5.2", "Lua 5.3", - "Lua 5.4" + "Lua 5.4", + "LuaJIT" ], "description": "Lua runtime version.\nLua运行版本。" }, diff --git a/server/libs/@lua/basic.lni b/server/libs/@lua/basic.lni index 14c4f669..13cf51a6 100644 --- a/server/libs/@lua/basic.lni +++ b/server/libs/@lua/basic.lni @@ -111,7 +111,7 @@ optional = 'self' type = 'table' [getfenv] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} [[.args]] name = f type = function @@ -201,7 +201,7 @@ default = true ['load Lua 5.1'] name = 'load' -version = {'Lua 5.1'} +version = 'Lua 5.1' [[.args]] name = 'func' type = 'function' @@ -274,7 +274,7 @@ name = 'error_message' type = 'string' [loadstring] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} [[.args]] type = string ````````` @@ -293,7 +293,7 @@ name = 'error_message' type = 'string' [module] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} special = 'module' [[.args]] name = name @@ -419,7 +419,7 @@ name = 'index' code = 'integer' [setfenv] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} [[.args]] name = f type = function/integer @@ -488,7 +488,7 @@ name = 'type' enum = 'userdata' ["_VERSION Lua 5.1"] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} name = '_VERSION' type = 'string' value = 'Lua 5.1' @@ -549,7 +549,7 @@ type = 'string' [[.returns]] [unpack] -version = {'Lua 5.1'} +version = {'Lua 5.1', 'LuaJIT'} [[.args]] name = 'list' type = 'table' diff --git a/server/libs/@lua/debug.lni b/server/libs/@lua/debug.lni index 74d50161..0d4def79 100644 --- a/server/libs/@lua/debug.lni +++ b/server/libs/@lua/debug.lni @@ -23,7 +23,7 @@ parent = { name = 'debug' [getfenv] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} [[.args]] name = o [[.returns]] @@ -79,6 +79,10 @@ enum = 'f' name = 'what' enum = 'L' +['getinfo Lua 5.1':getinfo] +name = 'getinfo' +version = 'Lua 5.1' + [getlocal] [[.args]] type = 'thread' @@ -90,6 +94,17 @@ type = {'integer', 'function'} name = 'local' type = 'integer' +['getlocal Lua 5.1'] +[[.args]] +type = 'thread' +optional = 'self' +`````````` +name = 'level' +type = integer' +`````````` +name = 'local' +type = 'integer' + [getmetatable] [[.args]] name = 'value' @@ -135,7 +150,7 @@ type = 'any' type = 'boolean' [setfenv] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} [[.args]] name = 'object' `````````` @@ -244,6 +259,7 @@ default = 1 name = 'message' [upvalueid] +version = {'Lua 5.2', 'Lua 5.3', 'Lua 5.4', 'LuaJIT'} [[.args]] name = 'f' type = 'function' @@ -255,6 +271,7 @@ name = 'id' type = 'userdata' [upvaluejoin] +version = {'Lua 5.2', 'Lua 5.3', 'Lua 5.4', 'LuaJIT'} [[.args]] name = 'f1' type = 'function' diff --git a/server/libs/@lua/io.lni b/server/libs/@lua/io.lni index bf59969f..d267a2e3 100644 --- a/server/libs/@lua/io.lni +++ b/server/libs/@lua/io.lni @@ -91,9 +91,6 @@ enum = '*l' default = true `````````` name = 'mode' -enum = '*L' -`````````` -name = 'mode' code = 'number' ["lines Lua 5.3"] @@ -131,6 +128,41 @@ enum = 'L' name = 'mode' code = 'number' +["lines LuaJIT"] +name = 'lines' +version = 'LuaJIT' +[[.args]] +name = 'filename' +type = 'string' +optional = 'after' +`````````` +name = 'mode' +type = '...' +[[.returns]] +type = 'function' +returns = { + 1 = { + name = 'c', + type = {'string', 'number'}, + } +} +[[.enums]] +name = 'mode' +enum = '*n' +`````````` +name = 'mode' +enum = '*a' +`````````` +name = 'mode' +enum = '*l' +default = true +`````````` +name = 'mode' +enum = '*L' +`````````` +name = 'mode' +code = 'number' + [open] [[.args]] name = 'filename' @@ -186,7 +218,7 @@ enum = 'w' ["read Lua 5.1"] name = 'read' -version = {'Lua 5.3', 'Lua 5.4'} +version = {'Lua 5.1', 'Lua 5.2'} [[.args]] name = 'mode' type = '...' @@ -206,9 +238,6 @@ enum = '*l' default = true `````````` name = 'mode' -enum = '*L' -`````````` -name = 'mode' code = 'number' ["read Lua 5.3"] @@ -238,6 +267,33 @@ enum = 'L' name = 'mode' code = 'number' +["read LuaJIT"] +name = 'read' +version = 'LuaJIT' +[[.args]] +name = 'mode' +type = '...' +[[.returns]] +type = {'string', 'number'} +`````````` +type = '...' +[[.enums]] +name = 'mode' +enum = '*n' +`````````` +name = 'mode' +enum = '*a' +`````````` +name = 'mode' +enum = '*l' +default = true +`````````` +name = 'mode' +enum = '*L' +`````````` +name = 'mode' +code = 'number' + [tmpfile] [[.returns]] type = 'FILE*' diff --git a/server/libs/@lua/math.lni b/server/libs/@lua/math.lni index 20f75315..ecc0360d 100644 --- a/server/libs/@lua/math.lni +++ b/server/libs/@lua/math.lni @@ -42,7 +42,7 @@ type = 'number' ["atan Lua 5.1"] name = 'atan' -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'y' type = 'number' @@ -64,7 +64,7 @@ default = 1 type = 'number' [atan2] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'y' type = 'number' @@ -91,7 +91,7 @@ type = 'number' type = 'number' [cosh] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'x' type = 'number' @@ -130,7 +130,7 @@ type = 'number' type = 'number' [frexp] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'x' type = 'number' @@ -145,7 +145,7 @@ type = 'number' type = 'number' [ldexp] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'm' type = 'number' @@ -169,7 +169,7 @@ type = 'number' ['log Lua 5.1'] name = log -version = {'Lua 5.1'} +version = 'Lua 5.1' [[.args]] name = 'x' type = 'number' @@ -221,7 +221,7 @@ type = 'number' type = 'number' [power] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'x' type = 'number' @@ -276,7 +276,7 @@ type = 'number' type = 'number' [sinh] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'x' type = 'number' @@ -298,7 +298,7 @@ type = 'number' type = 'number' [tanh] -version = {'Lua 5.1', 'Lua 5.2'} +version = {'Lua 5.1', 'Lua 5.2', 'LuaJIT'} [[.args]] name = 'x' type = 'number' diff --git a/server/libs/@lua/os.lni b/server/libs/@lua/os.lni index 64d5f1c9..8486075f 100644 --- a/server/libs/@lua/os.lni +++ b/server/libs/@lua/os.lni @@ -70,7 +70,7 @@ enum = 'signal' ['execute Lua 5.1'] name = 'execute' -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} [[.args]] name = 'command' type = 'string' @@ -90,6 +90,15 @@ name = 'close' type = 'boolean' optional = 'self' +['exit Lua 5.1'] +name = 'exit' +version = 'Lua 5.1' +[[.args]] +name = 'code' +type = 'integer' +optional = 'after' +default = 0 + [getenv] [[.args]] name = 'varname' diff --git a/server/libs/@lua/package.lni b/server/libs/@lua/package.lni index 43ae7344..4a520e89 100644 --- a/server/libs/@lua/package.lni +++ b/server/libs/@lua/package.lni @@ -29,7 +29,7 @@ type = 'string' type = 'table' [loaders] -version = {'Lua 5.1'} +version = {'Lua 5.1', 'LuaJIT'} type = 'table' [loadlib] @@ -52,6 +52,7 @@ version = {'Lua 5.2', 'Lua 5.3', 'Lua 5.4'} type = 'table' [searchpath] +version = {'Lua 5.2', 'Lua 5.3', 'Lua 5.4', 'LuaJIT'} [[.args]] name = 'name' type = 'string' @@ -69,7 +70,7 @@ type = 'string' optional = 'self' [seeall] -version = 'Lua 5.1' +version = {'Lua 5.1', 'LuaJIT'} special = seeall [[.args]] name = module diff --git a/server/libs/@lua/string.lni b/server/libs/@lua/string.lni index bd454fc0..55bfde8a 100644 --- a/server/libs/@lua/string.lni +++ b/server/libs/@lua/string.lni @@ -219,6 +219,17 @@ default = '' [[.returns]] type = 'string' +['rep Lua 5.1'] +name = rep +version = 'Lua 5.1' +[[.args]] +type = 'string' +`````````` +name = n +type = 'integer' +[[.returns]] +type = 'string' + [reverse] [[.args]] type = 'string' diff --git a/server/libs/@lua/table.lni b/server/libs/@lua/table.lni index c48417c3..347756da 100644 --- a/server/libs/@lua/table.lni +++ b/server/libs/@lua/table.lni @@ -53,7 +53,7 @@ name = 'value' type = 'any' [maxn] -version = {'Lua 5.1'} +version = {'Lua 5.1', 'LuaJIT'} [[.args]] type = table [[.returns]] diff --git a/server/locale/en-US/libs/@lua/debug.lni b/server/locale/en-US/libs/@lua/debug.lni index 42422ae6..4c7bd016 100644 --- a/server/locale/en-US/libs/@lua/debug.lni +++ b/server/locale/en-US/libs/@lua/debug.lni @@ -38,9 +38,43 @@ name = 'what' enum = 'L' description = '`activelines`' +['getinfo Lua 5.1'] +description = 'Returns a table with information about a function.' +[[.enums]] +name = 'what' +enum = 'n' +description = '`name` and `namewhat`' +`````````` +name = 'what' +enum = 'S' +description = '`source`, `short_src`, `linedefined`, `lastlinedefined`, and `what`' +`````````` +name = 'what' +enum = 'l' +description = '`currentline`' +`````````` +name = 'what' +enum = 't' +description = '`istailcall`' +`````````` +name = 'what' +enum = 'u' +description = '`nups`' +`````````` +name = 'what' +enum = 'f' +description = '`func`' +`````````` +name = 'what' +enum = 'L' +description = '`activelines`' + [getlocal] description = 'Returns the name and the value of the local variable with index `local` of the function at level `f` of the stack.' +['getlocal Lua 5.1'] +description = 'Returns the name and the value of the local variable with index `local` of the function at level `level` of the stack.' + [getmetatable] description = 'Returns the metatable of the given value.' diff --git a/server/locale/en-US/libs/@lua/io.lni b/server/locale/en-US/libs/@lua/io.lni index 6b25495f..68cf8830 100644 --- a/server/locale/en-US/libs/@lua/io.lni +++ b/server/locale/en-US/libs/@lua/io.lni @@ -39,10 +39,6 @@ enum = '*l' description = 'Reads the next line skipping the end of line.' `````````` name = 'mode' -enum = '*L' -description = 'Reads the next line keeping the end of line.' -`````````` -name = 'mode' code = 'number' description = 'Reads a string with up to this number of bytes.' @@ -76,6 +72,36 @@ name = 'mode' code = 'number' description = 'Reads a string with up to this number of bytes.' +["lines LuaJIT"] +description = [[ +------ +```lua +for c in io.lines(filename, ...) do + body +end +``` +]] +[[.enums]] +name = 'mode' +enum = '*n' +description = 'Reads a numeral and returns it as number.' +`````````` +name = 'mode' +enum = '*a' +description = 'Reads the whole file.' +`````````` +name = 'mode' +enum = '*l' +description = 'Reads the next line skipping the end of line.' +`````````` +name = 'mode' +enum = '*L' +description = 'Reads the next line keeping the end of line.' +`````````` +name = 'mode' +code = 'number' +description = 'Reads a string with up to this number of bytes.' + [open] description = 'Opens a file, in the mode specified in the string `mode`.' [[.enums]] @@ -133,10 +159,6 @@ enum = '*l' description = 'Reads the next line skipping the end of line.' `````````` name = 'mode' -enum = '*L' -description = 'Reads the next line keeping the end of line.' -`````````` -name = 'mode' code = 'number' description = 'Reads a string with up to this number of bytes.' @@ -163,6 +185,29 @@ name = 'mode' code = 'number' description = 'Reads a string with up to this number of bytes.' +["read LuaJIT"] +description = 'Reads the `file`, according to the given formats, which specify what to read.' +[[.enums]] +name = 'mode' +enum = '*n' +description = 'Reads a numeral and returns it as number.' +`````````` +name = 'mode' +enum = '*a' +description = 'Reads the whole file.' +`````````` +name = 'mode' +enum = '*l' +description = 'Reads the next line skipping the end of line.' +`````````` +name = 'mode' +enum = '*L' +description = 'Reads the next line keeping the end of line.' +`````````` +name = 'mode' +code = 'number' +description = 'Reads a string with up to this number of bytes.' + [tmpfile] description = 'In case of success, returns a handle for a temporary file.' diff --git a/server/locale/en-US/libs/@lua/os.lni b/server/locale/en-US/libs/@lua/os.lni index 8be67434..82b7c228 100644 --- a/server/locale/en-US/libs/@lua/os.lni +++ b/server/locale/en-US/libs/@lua/os.lni @@ -16,6 +16,9 @@ description = 'Passes `command` to be executed by an operating system shell.' [exit] description = 'Calls the ISO C function `exit` to terminate the host program.' +['exit Lua 5.1'] +description = 'Calls the C function `exit` to terminate the host program.' + [getenv] description = 'Returns the value of the process environment variable `varname`.' diff --git a/server/locale/en-US/libs/@lua/string.lni b/server/locale/en-US/libs/@lua/string.lni index 3c7b987d..2055b16b 100644 --- a/server/locale/en-US/libs/@lua/string.lni +++ b/server/locale/en-US/libs/@lua/string.lni @@ -56,6 +56,9 @@ description = 'Returns the size of a string resulting from `string.pack` with th [rep] description = 'Returns a string that is the concatenation of `n` copies of the string `s` separated by the string `sep`.' +['rep Lua 5.1'] +description = 'Returns a string that is the concatenation of `n` copies of the string `s` .' + [reverse] description = 'Returns a string that is the string `s` reversed.' diff --git a/server/locale/zh-CN/libs/@lua/debug.lni b/server/locale/zh-CN/libs/@lua/debug.lni index 22e6d3b3..8783b8e3 100644 --- a/server/locale/zh-CN/libs/@lua/debug.lni +++ b/server/locale/zh-CN/libs/@lua/debug.lni @@ -38,8 +38,42 @@ name = 'what' enum = 'L' description = '`activelines`' +['getinfo Lua 5.1'] +description = '返回关于一个函数信息的表。' +[[.enums]] +name = 'what' +enum = 'n' +description = '`name` 和 `namewhat`' +`````````` +name = 'what' +enum = 'S' +description = '`source`,`short_src`,`linedefined`,`lastlinedefined`,和 `what`' +`````````` +name = 'what' +enum = 'l' +description = '`currentline`' +`````````` +name = 'what' +enum = 't' +description = '`istailcall`' +`````````` +name = 'what' +enum = 'u' +description = '`nups`' +`````````` +name = 'what' +enum = 'f' +description = '`func`' +`````````` +name = 'what' +enum = 'L' +description = '`activelines`' + [getlocal] -description = '返回在栈的 `f` 层处函数的索引为 `local` 的局部变量 的名字和值。' +description = '返回在栈的 `f` 层处函数的索引为 `local` 的局部变量的名字和值。' + +['getlocal Lua 5.1'] +description = '返回在栈的 `level` 层处函数的索引为 `local` 的局部变量的名字和值。' [getmetatable] description = '返回给定 `value` 的元表。' diff --git a/server/locale/zh-CN/libs/@lua/io.lni b/server/locale/zh-CN/libs/@lua/io.lni index 4a8a72a0..8881777f 100644 --- a/server/locale/zh-CN/libs/@lua/io.lni +++ b/server/locale/zh-CN/libs/@lua/io.lni @@ -39,10 +39,6 @@ enum = '*l' description = '读取一行并忽略行结束标记。' `````````` name = 'mode' -enum = '*L' -description = '读取一行并保留行结束标记。' -`````````` -name = 'mode' code = 'number' description = '读取一个不超过这个数量字节数的字符串。' @@ -76,6 +72,36 @@ name = 'mode' code = 'number' description = '读取一个不超过这个数量字节数的字符串。' +["lines LuaJIT"] +description = [[ +------ +```lua +for c in io.lines(filename, ...) do + body +end +``` +]] +[[.enums]] +name = 'mode' +enum = '*n' +description = '读取一个数字,根据 Lua 的转换文法返回浮点数或整数。' +`````````` +name = 'mode' +enum = '*a' +description = '从当前位置开始读取整个文件。' +`````````` +name = 'mode' +enum = '*l' +description = '读取一行并忽略行结束标记。' +`````````` +name = 'mode' +enum = '*L' +description = '读取一行并保留行结束标记。' +`````````` +name = 'mode' +code = 'number' +description = '读取一个不超过这个数量字节数的字符串。' + [open] description = '用字符串 `mode` 指定的模式打开一个文件。' [[.enums]] @@ -133,10 +159,6 @@ enum = '*l' description = '读取一行并忽略行结束标记。' `````````` name = 'mode' -enum = '*L' -description = '读取一行并保留行结束标记。' -`````````` -name = 'mode' code = 'number' description = '读取一个不超过这个数量字节数的字符串。' @@ -163,6 +185,29 @@ name = 'mode' code = 'number' description = '读取一个不超过这个数量字节数的字符串。' +["read LuaJIT"] +description = '读文件 `file`, 指定的格式决定了要读什么。' +[[.enums]] +name = 'mode' +enum = '*n' +description = '读取一个数字,根据 Lua 的转换文法返回浮点数或整数。' +`````````` +name = 'mode' +enum = '*a' +description = '从当前位置开始读取整个文件。' +`````````` +name = 'mode' +enum = '*l' +description = '读取一行并忽略行结束标记。' +`````````` +name = 'mode' +enum = '*L' +description = '读取一行并保留行结束标记。' +`````````` +name = 'mode' +code = 'number' +description = '读取一个不超过这个数量字节数的字符串。' + [tmpfile] description = '如果成功,返回一个临时文件的句柄。' diff --git a/server/locale/zh-CN/libs/@lua/os.lni b/server/locale/zh-CN/libs/@lua/os.lni index 6a4bcf0f..e3702667 100644 --- a/server/locale/zh-CN/libs/@lua/os.lni +++ b/server/locale/zh-CN/libs/@lua/os.lni @@ -16,6 +16,9 @@ description = '调用系统解释器执行 `command`。' [exit] description = '调用 ISO C 函数 `exit` 终止宿主程序。' +['exit Lua 5.1'] +description = '调用 C 函数 `exit` 终止宿主程序。' + [getenv] description = '返回进程环境变量 `varname` 的值。' diff --git a/server/locale/zh-CN/libs/@lua/string.lni b/server/locale/zh-CN/libs/@lua/string.lni index cc582783..6aa78cce 100644 --- a/server/locale/zh-CN/libs/@lua/string.lni +++ b/server/locale/zh-CN/libs/@lua/string.lni @@ -45,6 +45,9 @@ description = '返回以指定格式用 `string.pack` 打包的字符串的长 [rep] description = '返回 `n` 个字符串 `s` 以字符串 `sep` 为分割符连在一起的字符串。' +['rep Lua 5.1'] +description = '返回 `n` 个字符串 `s` 连在一起的字符串。' + [reverse] description = '返回字符串的翻转串。' diff --git a/server/main.lua b/server/main.lua index 1895f804..dd0c53d3 100644 --- a/server/main.lua +++ b/server/main.lua @@ -21,7 +21,7 @@ local function tryDebugger() log.info('Debugger startup, listen port: 11411') end ---pcall(tryDebugger) +pcall(tryDebugger) require 'utility' require 'global_protect' |