mirror of
https://github.com/Adorable-Catgirl/LuaComp.git
synced 2024-11-23 02:18:06 +11:00
☢!!WARNING!!☢
This commit is contained in:
parent
eae215ec07
commit
bb1bf0cf1b
@ -10,6 +10,7 @@
|
||||
--#include "src/directives/include.lua"
|
||||
--#include "src/directives/loadmod.lua"
|
||||
--#include "src/directives/error.lua"
|
||||
--#include "src/directives/warning.lua"
|
||||
|
||||
setmetatable(directives, {__index=function(t, i)
|
||||
for i=1, #directive_paths do
|
||||
|
@ -5,11 +5,13 @@
|
||||
local warned = false
|
||||
function directives.loadmod(env, mod)
|
||||
if not warned then
|
||||
io.stderr:write("Warning: loadmod is depreciated and unsafe. The API differs from luapreproc. Use the include paths!\n")
|
||||
lc_warning("@[{_GENERATOR.fname}]", "loadmod is depreciated and unsafe. The API differs from luapreproc. Use the include paths!")
|
||||
warned = true
|
||||
end
|
||||
if (not os.execute("stat "..file..">/dev/null")) then
|
||||
return false, "Module `"..file.."' does not exist!"
|
||||
--if (not os.execute("stat "..file..">/dev/null")) then
|
||||
local sr, se = stat.stat(file)
|
||||
if not sr then
|
||||
return false, se
|
||||
end
|
||||
local modname, func = dofile(mod)
|
||||
directives[modname] = func
|
||||
|
4
src/directives/warning.lua
Normal file
4
src/directives/warning.lua
Normal file
@ -0,0 +1,4 @@
|
||||
function directives.warning(env, msg)
|
||||
lc_warning(env.fname, msg)
|
||||
return true
|
||||
end
|
@ -5,13 +5,17 @@
|
||||
|
||||
local luacomp = {}
|
||||
|
||||
if arg and arg[0] == "luacomp" then
|
||||
_G.luacomp = luacomp
|
||||
end
|
||||
|
||||
local directives = {}
|
||||
|
||||
local unistd = require("posix.unistd")
|
||||
|
||||
local function lc_error(name, msg)
|
||||
if unistd.isatty(2) then
|
||||
io.stderr:write(string.format("\27[90;1m(%s) \27[31;22m%s\27[0m\n", name, msg))
|
||||
io.stderr:write(string.format("\27[90;1m(%s) \27[31merror: \27[22m%s\27[0m\n", name, msg))
|
||||
else
|
||||
io.stderr:write(string.format("(%s) %s\n", name, msg))
|
||||
end
|
||||
@ -20,7 +24,7 @@ end
|
||||
|
||||
local function lc_warning(name, msg)
|
||||
if unistd.isatty(2) then
|
||||
io.stderr:write(string.format("\27[90;1m(%s) \27[33;22m%s\27[0m\n", name, msg))
|
||||
io.stderr:write(string.format("\27[90;1m(%s) \27[33mwarning: \27[22m%s\27[0m\n", name, msg))
|
||||
else
|
||||
io.stderr:write(string.format("(%s) %s\n", name, msg))
|
||||
end
|
||||
|
@ -10,6 +10,6 @@ end
|
||||
|
||||
_sv("LUACOMP_V_MAJ", 2)
|
||||
_sv("LUACOMP_V_MIN", 0)
|
||||
_sv("LUACOMP_V_PAT", 1)
|
||||
_sv("LUACOMP_V_PAT", 2)
|
||||
_sv("LUACOMP_VERSION", LUACOMP_V_MAJ.."."..LUACOMP_V_MIN.."."..LUACOMP_V_PAT)
|
||||
_sv("LUACOMP_NAME", "LuaComp")
|
1
tests/warning.lua
Normal file
1
tests/warning.lua
Normal file
@ -0,0 +1 @@
|
||||
--#warning "test"
|
Loading…
Reference in New Issue
Block a user