Lunatic: remove DBG_ variable for _DEBUG_LUNATIC=0.

git-svn-id: https://svn.eduke32.com/eduke32@3966 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-07-19 12:49:06 +00:00
parent ac3a6a1bd2
commit 7860fb8c01
2 changed files with 37 additions and 25 deletions

View file

@ -1704,6 +1704,11 @@ local function our_require(modname, ...)
error("module name must be a nonempty string", 2) error("module name must be a nonempty string", 2)
end end
-- For _LUNATIC_DBG
if (modname:match("^_LUNATIC") and ffiC._DEBUG_LUNATIC == 0) then
return nil
end
-- Handle the section between module() and require("end_gamevars"). -- Handle the section between module() and require("end_gamevars").
if (modname == "end_gamevars") then if (modname == "end_gamevars") then
local thismodname = getcurmodname("require") local thismodname = getcurmodname("require")
@ -2371,19 +2376,20 @@ gv = setmtonce(gv_, tmpmt)
defs_c.create_globals(_G) defs_c.create_globals(_G)
-- REMOVE this for release -- REMOVE this for release
DBG_ = {} if (ffiC._DEBUG_LUNATIC ~= 0) then
DBG_.debug = require("debug") local DBG_ = {}
DBG_.printkv = printkv DBG_.debug = require("debug")
DBG_.loadstring = loadstring DBG_.printkv = printkv
DBG_.oom = function() DBG_.loadstring = loadstring
DBG_.oom = function()
local s = "1" local s = "1"
for i=1,math.huge do for i=1,math.huge do
s = s..s s = s..s
end end
end end
-- Test reading from all struct members -- Test reading from all struct members
function DBG_.testmembread() DBG_.testmembread = function()
for _1, sac in pairs { con_lang.StructAccessCode, con_lang.StructAccessCode2 } do for _1, sac in pairs { con_lang.StructAccessCode, con_lang.StructAccessCode2 } do
for what, labels in pairs(sac) do for what, labels in pairs(sac) do
if (what~="tspr") then if (what~="tspr") then
@ -2405,8 +2411,10 @@ local tmp=]]..
end end
end end
end end
end end
allowed_modules._LUNATIC_DBG = DBG_
end
---=== Finishing environment setup ===--- ---=== Finishing environment setup ===---

View file

@ -6,7 +6,7 @@ local bit = require("bit")
local math = require("math") local math = require("math")
local pcall = pcall local pcall = pcall
local DBG_ = DBG_ local DBG_ = require("_LUNATIC_DBG")
print('---=== ELua Test script ===---') print('---=== ELua Test script ===---')
@ -15,6 +15,10 @@ local function printf(fmt, ...)
end end
local function checkfail(funcstr, expectedmsg) local function checkfail(funcstr, expectedmsg)
if (DBG_ == nil) then
return
end
local status, errmsg = pcall(DBG_.loadstring(funcstr)) local status, errmsg = pcall(DBG_.loadstring(funcstr))
if (status) then if (status) then
print('^21ERROR:^O '..funcstr.." DIDN'T fail") print('^21ERROR:^O '..funcstr.." DIDN'T fail")
@ -275,7 +279,7 @@ gameevent
gv.EVENT_ENTERLEVEL, gv.EVENT_ENTERLEVEL,
function() function()
if (gv._DEBUG_LUNATIC) then if (DBG_ ~= nil) then
DBG_.testmembread() DBG_.testmembread()
end end