From 1827e053fa17863a7a3632a731540176648242ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 18 Nov 2020 21:04:39 +0800 Subject: =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=89=88=E6=9C=AC=E9=A2=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/library.lua | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'script-beta/library.lua') diff --git a/script-beta/library.lua b/script-beta/library.lua index ffe016ec..a8c45738 100644 --- a/script-beta/library.lua +++ b/script-beta/library.lua @@ -345,12 +345,22 @@ local function compileSingleMetaDoc(script, metaLang) end middleBuf[#middleBuf+1] = ('PUSH [===[%s]===]'):format(script:sub(last)) local middleScript = table.concat(middleBuf, '\n') + local version, jit + if config.config.runtime.version == 'LuaJIT' then + version = 5.1 + jit = true + else + version = tonumber(config.config.runtime.version:sub(-3)) + jit = false + end local env = setmetatable({ - PUSH = function (text) + VERSION = version, + JIT = jit, + PUSH = function (text) compileBuf[#compileBuf+1] = text end, - DES = function (name) + DES = function (name) local des = metaLang[name] if not des then des = ('Miss locale <%s>'):format(name) @@ -377,16 +387,35 @@ local function compileSingleMetaDoc(script, metaLang) compileBuf[#compileBuf+1] = convertLink(des) compileBuf[#compileBuf+1] = '\n' end, + ALIVE = function (str) + local isAlive + for piece in str:gmatch '[^%,]+' do + if piece:sub(1, 1) == '>' then + local alive = tonumber(piece:sub(2)) + if not alive or version >= alive then + isAlive = true + break + end + elseif piece:sub(1, 1) == '<' then + local alive = tonumber(piece:sub(2)) + if not alive or version <= alive then + isAlive = true + break + end + else + local alive = tonumber(piece) + if not alive or version == alive then + isAlive = true + break + end + end + end + if not isAlive then + compileBuf[#compileBuf+1] = '---@deprecated\n' + end + end, }, { __index = _ENV }) - if config.config.runtime.version == 'LuaJIT' then - env.VERSION = 5.1 - env.JIT = true - else - env.VERSION = tonumber(config.config.runtime.version:sub(-3)) - env.JIT = false - end - util.saveFile((ROOT / 'log' / 'middleScript.lua'):string(), middleScript) assert(load(middleScript, middleScript, 't', env))() -- cgit v1.2.3