1
0
mirror of https://github.com/Adorable-Catgirl/LuaComp.git synced 2024-11-23 10:28:06 +11:00

☢!!WARNING!!☢

This commit is contained in:
Sam Roxanne 2021-06-25 11:35:25 -05:00
parent eae215ec07
commit bb1bf0cf1b
6 changed files with 18 additions and 6 deletions

View File

@ -10,6 +10,7 @@
--#include "src/directives/include.lua" --#include "src/directives/include.lua"
--#include "src/directives/loadmod.lua" --#include "src/directives/loadmod.lua"
--#include "src/directives/error.lua" --#include "src/directives/error.lua"
--#include "src/directives/warning.lua"
setmetatable(directives, {__index=function(t, i) setmetatable(directives, {__index=function(t, i)
for i=1, #directive_paths do for i=1, #directive_paths do

View File

@ -5,11 +5,13 @@
local warned = false local warned = false
function directives.loadmod(env, mod) function directives.loadmod(env, mod)
if not warned then 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 warned = true
end end
if (not os.execute("stat "..file..">/dev/null")) then --if (not os.execute("stat "..file..">/dev/null")) then
return false, "Module `"..file.."' does not exist!" local sr, se = stat.stat(file)
if not sr then
return false, se
end end
local modname, func = dofile(mod) local modname, func = dofile(mod)
directives[modname] = func directives[modname] = func

View File

@ -0,0 +1,4 @@
function directives.warning(env, msg)
lc_warning(env.fname, msg)
return true
end

View File

@ -5,13 +5,17 @@
local luacomp = {} local luacomp = {}
if arg and arg[0] == "luacomp" then
_G.luacomp = luacomp
end
local directives = {} local directives = {}
local unistd = require("posix.unistd") local unistd = require("posix.unistd")
local function lc_error(name, msg) local function lc_error(name, msg)
if unistd.isatty(2) then 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 else
io.stderr:write(string.format("(%s) %s\n", name, msg)) io.stderr:write(string.format("(%s) %s\n", name, msg))
end end
@ -20,7 +24,7 @@ end
local function lc_warning(name, msg) local function lc_warning(name, msg)
if unistd.isatty(2) then 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 else
io.stderr:write(string.format("(%s) %s\n", name, msg)) io.stderr:write(string.format("(%s) %s\n", name, msg))
end end

View File

@ -10,6 +10,6 @@ end
_sv("LUACOMP_V_MAJ", 2) _sv("LUACOMP_V_MAJ", 2)
_sv("LUACOMP_V_MIN", 0) _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_VERSION", LUACOMP_V_MAJ.."."..LUACOMP_V_MIN.."."..LUACOMP_V_PAT)
_sv("LUACOMP_NAME", "LuaComp") _sv("LUACOMP_NAME", "LuaComp")

1
tests/warning.lua Normal file
View File

@ -0,0 +1 @@
--#warning "test"